libmicrohttpd

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

commit 705bb243b0edb4fecdab4e892f4e1cc130d36505
parent d8e2c71150f270efa38e40a33c8dda133349d231
Author: Christian Grothoff <christian@grothoff.org>
Date:   Mon, 13 Oct 2008 02:03:03 +0000

indentation

Diffstat:
Mconfigure.ac | 2++
Mdoc/examples/largepost.c | 166++++++++++++++++++++++++++++++++++++++++++++++---------------------------------
Mdoc/examples/tlsauthentication.c | 44+++++++++++++++++++++++++-------------------
Msrc/daemon/connection.c | 167++++++++++++++++++++++++++++++++++++++-----------------------------------------
Msrc/daemon/connection_https.c | 62++++++++++++++++++++++++++++++++------------------------------
Msrc/daemon/daemon.c | 184++++++++++++++++++++++++++++++++++++++-----------------------------------------
Msrc/daemon/https/gnutls.h | 284++++++++++++++++++++++++++++++++++++++++++-------------------------------------
Msrc/daemon/https/lgl/des.c | 14+++++++++-----
Msrc/daemon/https/lgl/des.h | 14+++++++++-----
Msrc/daemon/https/lgl/gc-gnulib.c | 45+++++++++++++++++++++++++++------------------
Msrc/daemon/https/lgl/gc-libgcrypt.c | 33++++++++++++++++++++-------------
Msrc/daemon/https/lgl/gc-pbkdf2-sha1.c | 4++--
Msrc/daemon/https/lgl/gc.h | 54+++++++++++++++++++++++++++++++-----------------------
Msrc/daemon/https/lgl/hmac-md5.c | 2+-
Msrc/daemon/https/lgl/hmac-sha1.c | 2+-
Msrc/daemon/https/lgl/hmac.h | 4++--
Msrc/daemon/https/lgl/md5.c | 6++++--
Msrc/daemon/https/lgl/md5.h | 10+++++-----
Msrc/daemon/https/lgl/rijndael-alg-fst.c | 8++++----
Msrc/daemon/https/lgl/rijndael-alg-fst.h | 8++++----
Msrc/daemon/https/lgl/rijndael-api-fst.c | 24+++++++++++++-----------
Msrc/daemon/https/lgl/rijndael-api-fst.h | 24++++++++++++++----------
Msrc/daemon/https/lgl/sha1.c | 9++++++---
Msrc/daemon/https/lgl/sha1.h | 4++--
Msrc/daemon/https/minitasn1/coding.c | 149++++++++++++++++++++++++++++++++++++++++++++-----------------------------------
Msrc/daemon/https/minitasn1/decoding.c | 156++++++++++++++++++++++++++++++++++++++++++++++----------------------------------
Msrc/daemon/https/minitasn1/element.c | 123+++++++++++++++++++++++++++++++++++++++++--------------------------------------
Msrc/daemon/https/minitasn1/element.h | 4++--
Msrc/daemon/https/minitasn1/libtasn1.h | 77++++++++++++++++++++++++++++++++++++++++++-----------------------------------
Msrc/daemon/https/minitasn1/parser_aux.c | 31+++++++++++++++++++------------
Msrc/daemon/https/minitasn1/parser_aux.h | 2+-
Msrc/daemon/https/minitasn1/structure.c | 17++++++++++-------
Msrc/daemon/https/tls/auth_cert.c | 40+++++++++++++++++++++++-----------------
Msrc/daemon/https/tls/auth_cert.h | 6+++---
Msrc/daemon/https/tls/auth_rsa.c | 25+++++++++++++------------
Msrc/daemon/https/tls/auth_rsa_export.c | 2+-
Msrc/daemon/https/tls/debug.c | 15+++++++++------
Msrc/daemon/https/tls/debug.h | 3++-
Msrc/daemon/https/tls/ext_cert_type.c | 7++++---
Msrc/daemon/https/tls/ext_max_record.c | 4++--
Msrc/daemon/https/tls/ext_oprfi.c | 20++++++++++++--------
Msrc/daemon/https/tls/ext_server_name.c | 48++++++++++++++++++++++++------------------------
Msrc/daemon/https/tls/gnutls_alert.c | 7++++---
Msrc/daemon/https/tls/gnutls_algorithms.c | 51+++++++++++++++++++++++++++------------------------
Msrc/daemon/https/tls/gnutls_algorithms.h | 16+++++++++-------
Msrc/daemon/https/tls/gnutls_anon_cred.c | 11+++++------
Msrc/daemon/https/tls/gnutls_auth.c | 15++++++++-------
Msrc/daemon/https/tls/gnutls_buffers.c | 97++++++++++++++++++++++++++++++++++++++++++-------------------------------------
Msrc/daemon/https/tls/gnutls_cert.c | 26++++++++++++++++----------
Msrc/daemon/https/tls/gnutls_cert.h | 3++-
Msrc/daemon/https/tls/gnutls_cipher.c | 45+++++++++++++++++++++++----------------------
Msrc/daemon/https/tls/gnutls_cipher.h | 3++-
Msrc/daemon/https/tls/gnutls_cipher_int.c | 10++++++----
Msrc/daemon/https/tls/gnutls_compress.c | 8++++----
Msrc/daemon/https/tls/gnutls_compress.h | 9+++++----
Msrc/daemon/https/tls/gnutls_compress_int.c | 21+++++++++++----------
Msrc/daemon/https/tls/gnutls_constate.c | 170++++++++++++++++++++++++++++++++++++++++---------------------------------------
Msrc/daemon/https/tls/gnutls_datum.c | 3++-
Msrc/daemon/https/tls/gnutls_datum.h | 3++-
Msrc/daemon/https/tls/gnutls_dh_primes.c | 2+-
Msrc/daemon/https/tls/gnutls_extensions.c | 15++++++++-------
Msrc/daemon/https/tls/gnutls_global.c | 24++++++++++++++----------
Msrc/daemon/https/tls/gnutls_handshake.c | 244+++++++++++++++++++++++++++++++++++++++++++------------------------------------
Msrc/daemon/https/tls/gnutls_handshake.h | 3++-
Msrc/daemon/https/tls/gnutls_hash_int.c | 9+++++----
Msrc/daemon/https/tls/gnutls_hash_int.h | 2+-
Msrc/daemon/https/tls/gnutls_kx.c | 119++++++++++++++++++++++++++++++++++++++++++++-----------------------------------
Msrc/daemon/https/tls/gnutls_mem.c | 3++-
Msrc/daemon/https/tls/gnutls_mpi.c | 3++-
Msrc/daemon/https/tls/gnutls_pk.c | 31++++++++++++++++---------------
Msrc/daemon/https/tls/gnutls_pk.h | 4++--
Msrc/daemon/https/tls/gnutls_priority.c | 19++++++++++---------
Msrc/daemon/https/tls/gnutls_record.c | 58++++++++++++++++++++++++++++++----------------------------
Msrc/daemon/https/tls/gnutls_rsa_export.c | 1-
Msrc/daemon/https/tls/gnutls_rsa_export.h | 1-
Msrc/daemon/https/tls/gnutls_session.c | 1-
Msrc/daemon/https/tls/gnutls_session_pack.c | 91+++++++++++++++++++++++++++++++++++++++++++------------------------------------
Msrc/daemon/https/tls/gnutls_sig.c | 58+++++++++++++++++++++++++++++++++-------------------------
Msrc/daemon/https/tls/gnutls_sig.h | 3++-
Msrc/daemon/https/tls/gnutls_state.c | 72+++++++++++++++++++++++++++++++++++++-----------------------------------
Msrc/daemon/https/tls/gnutls_state.h | 8++++----
Msrc/daemon/https/tls/gnutls_str.h | 3++-
Msrc/daemon/https/tls/gnutls_supplemental.c | 15+++++++++------
Msrc/daemon/https/tls/gnutls_supplemental.h | 4++--
Msrc/daemon/https/tls/gnutls_ui.c | 38++++++++++++++++++++------------------
Msrc/daemon/https/tls/gnutls_x509.c | 113++++++++++++++++++++++++++++++++++++++++++++-----------------------------------
Msrc/daemon/https/tls/gnutls_x509.h | 16+++++++++-------
Msrc/daemon/https/tls/x509_b64.c | 25++++++++++++-------------
Msrc/daemon/https/tls/x509_b64.h | 6+++---
Msrc/daemon/https/x509/common.c | 108++++++++++++++++++++++++++++++++++++++++++++++---------------------------------
Msrc/daemon/https/x509/common.h | 64+++++++++++++++++++++++++++++++++-------------------------------
Msrc/daemon/https/x509/crl.c | 74++++++++++++++++++++++++++++++++++++++++----------------------------------
Msrc/daemon/https/x509/crq.c | 123+++++++++++++++++++++++++++++++++++++++++++------------------------------------
Msrc/daemon/https/x509/dn.c | 160+++++++++++++++++++++++++++++++++++++++++++++++--------------------------------
Msrc/daemon/https/x509/dn.h | 20+++++++++++---------
Msrc/daemon/https/x509/dsa.h | 3++-
Msrc/daemon/https/x509/extensions.c | 25+++++++++++++++----------
Msrc/daemon/https/x509/extensions.h | 19++++++++++---------
Msrc/daemon/https/x509/mpi.c | 56++++++++++++++++++++++++++++++++------------------------
Msrc/daemon/https/x509/mpi.h | 33++++++++++++++++++---------------
Msrc/daemon/https/x509/pkcs12.h | 43+++++++++++++++++++++++--------------------
Msrc/daemon/https/x509/pkcs12_encr.c | 12++++++------
Msrc/daemon/https/x509/pkcs7.c | 46++++++++++++++++++++++++++--------------------
Msrc/daemon/https/x509/privkey.h | 5+++--
Msrc/daemon/https/x509/privkey_pkcs8.c | 102+++++++++++++++++++++++++++++++++++++++++++------------------------------------
Msrc/daemon/https/x509/rfc2818_hostname.c | 9+++++----
Msrc/daemon/https/x509/sign.c | 35++++++++++++++++++++---------------
Msrc/daemon/https/x509/sign.h | 6+++---
Msrc/daemon/https/x509/verify.h | 12+++++++-----
Msrc/daemon/https/x509/x509.c | 147+++++++++++++++++++++++++++++++++++++++++++------------------------------------
Msrc/daemon/https/x509/x509.h | 520+++++++++++++++++++++++++++++++++++++++++--------------------------------------
Msrc/daemon/https/x509/x509_privkey.c | 94++++++++++++++++++++++++++++++++++++++++++++-----------------------------------
Msrc/daemon/https/x509/x509_verify.c | 139+++++++++++++++++++++++++++++++++++++++++++------------------------------------
Msrc/daemon/internal.c | 4+---
Msrc/daemon/internal.h | 10++++------
Msrc/examples/https_fileserver_example.c | 44++++++++++++++++++++++----------------------
Msrc/examples/refuse_post_example.c | 24++++++++++++++----------
Msrc/include/microhttpd.h | 16++++++++--------
Msrc/testcurl/https/mhds_session_info_test.c | 20++++++++++----------
119 files changed, 2911 insertions(+), 2454 deletions(-)

diff --git a/configure.ac b/configure.ac @@ -141,6 +141,7 @@ AC_CHECK_HEADERS([sys/select.h sys/types.h sys/time.h sys/msg.h netdb.h netinet/ # IPv6 AC_MSG_CHECKING(for IPv6) AC_TRY_COMPILE([ +#include <stdio.h> #if HAVE_NETINET_IN_H #include <netinet/in.h> #endif @@ -151,6 +152,7 @@ AC_TRY_COMPILE([ int af=AF_INET6; int pf=PF_INET6; struct sockaddr_in6 sa; +printf("%d %d %p\n", af, pf, &sa); ],[ have_inet6=yes; AC_DEFINE([HAVE_INET6], [1], [Provides IPv6 headers]) diff --git a/doc/examples/largepost.c b/doc/examples/largepost.c @@ -11,18 +11,18 @@ #define GET 0 #define POST 1 -static unsigned char nr_of_uploading_clients = 0; +static unsigned char nr_of_uploading_clients = 0; struct connection_info_struct { int connectiontype; - struct MHD_PostProcessor *postprocessor; + struct MHD_PostProcessor *postprocessor; FILE *fp; const char *answerstring; int answercode; }; -const char* askpage = "<html><body>\n\ +const char *askpage = "<html><body>\n\ Upload a file, please!<br>\n\ There are %d clients uploading at the moment.<br>\n\ <form action=\"/filepost\" method=\"post\" enctype=\"multipart/form-data\">\n\ @@ -30,25 +30,34 @@ const char* askpage = "<html><body>\n\ <input type=\"submit\" value=\" Send \"></form>\n\ </body></html>"; -const char* busypage = "<html><body>This server is busy, please try again later.</body></html>"; +const char *busypage = + "<html><body>This server is busy, please try again later.</body></html>"; -const char* completepage = "<html><body>The upload has been completed.</body></html>"; +const char *completepage = + "<html><body>The upload has been completed.</body></html>"; -const char* errorpage = "<html><body>This doesn't seem to be right.</body></html>"; -const char* servererrorpage = "<html><body>An internal server error has occured.</body></html>"; -const char* fileexistspage = "<html><body>This file already exists.</body></html>"; +const char *errorpage = + "<html><body>This doesn't seem to be right.</body></html>"; +const char *servererrorpage = + "<html><body>An internal server error has occured.</body></html>"; +const char *fileexistspage = + "<html><body>This file already exists.</body></html>"; -int -send_page (struct MHD_Connection *connection, const char* page, int status_code) +int +send_page (struct MHD_Connection *connection, const char *page, + int status_code) { int ret; struct MHD_Response *response; - - response = MHD_create_response_from_data (strlen (page), (void*) page, MHD_NO, MHD_YES); - if (!response) return MHD_NO; - + + response = + MHD_create_response_from_data (strlen (page), (void *) page, MHD_NO, + MHD_YES); + if (!response) + return MHD_NO; + ret = MHD_queue_response (connection, status_code, response); MHD_destroy_response (response); @@ -56,36 +65,41 @@ send_page (struct MHD_Connection *connection, const char* page, int status_code) } -int +int iterate_post (void *coninfo_cls, enum MHD_ValueKind kind, const char *key, const char *filename, const char *content_type, - const char *transfer_encoding, const char *data, size_t off, size_t size) + const char *transfer_encoding, const char *data, size_t off, + size_t size) { FILE *fp; - struct connection_info_struct *con_info = (struct connection_info_struct*) coninfo_cls; + struct connection_info_struct *con_info = + (struct connection_info_struct *) coninfo_cls; con_info->answerstring = servererrorpage; con_info->answercode = MHD_HTTP_INTERNAL_SERVER_ERROR; - if (0 != strcmp (key, "file")) return MHD_NO; + if (0 != strcmp (key, "file")) + return MHD_NO; if (!con_info->fp) { - if (NULL != (fp = fopen (filename, "r")) ) + if (NULL != (fp = fopen (filename, "r"))) { fclose (fp); con_info->answerstring = fileexistspage; con_info->answercode = MHD_HTTP_FORBIDDEN; return MHD_NO; } - + con_info->fp = fopen (filename, "ab"); - if (!con_info->fp) return MHD_NO; + if (!con_info->fp) + return MHD_NO; } - - if (size > 0) - { - if (!fwrite (data, size, sizeof(char), con_info->fp)) return MHD_NO; + + if (size > 0) + { + if (!fwrite (data, size, sizeof (char), con_info->fp)) + return MHD_NO; } con_info->answerstring = completepage; @@ -94,95 +108,105 @@ iterate_post (void *coninfo_cls, enum MHD_ValueKind kind, const char *key, return MHD_YES; } -void +void request_completed (void *cls, struct MHD_Connection *connection, void **con_cls, enum MHD_RequestTerminationCode toe) { - struct connection_info_struct *con_info = (struct connection_info_struct*) *con_cls; + struct connection_info_struct *con_info = + (struct connection_info_struct *) *con_cls; - if (NULL == con_info) return; + if (NULL == con_info) + return; if (con_info->connectiontype == POST) { - if (NULL != con_info->postprocessor) + if (NULL != con_info->postprocessor) { - MHD_destroy_post_processor (con_info->postprocessor); + MHD_destroy_post_processor (con_info->postprocessor); nr_of_uploading_clients--; } - if (con_info->fp) fclose (con_info->fp); + if (con_info->fp) + fclose (con_info->fp); } free (con_info); - *con_cls = NULL; + *con_cls = NULL; } -int -answer_to_connection (void *cls, struct MHD_Connection *connection, const char *url, - const char *method, const char *version, const char *upload_data, +int +answer_to_connection (void *cls, struct MHD_Connection *connection, + const char *url, const char *method, + const char *version, const char *upload_data, unsigned int *upload_data_size, void **con_cls) { - if (NULL == *con_cls) + if (NULL == *con_cls) { struct connection_info_struct *con_info; if (nr_of_uploading_clients >= MAXCLIENTS) - return send_page(connection, busypage, MHD_HTTP_SERVICE_UNAVAILABLE); - + return send_page (connection, busypage, MHD_HTTP_SERVICE_UNAVAILABLE); + con_info = malloc (sizeof (struct connection_info_struct)); - if (NULL == con_info) return MHD_NO; + if (NULL == con_info) + return MHD_NO; con_info->fp = NULL; - if (0 == strcmp (method, "POST")) - { - con_info->postprocessor = MHD_create_post_processor (connection, POSTBUFFERSIZE, - iterate_post, (void*) con_info); + if (0 == strcmp (method, "POST")) + { + con_info->postprocessor = + MHD_create_post_processor (connection, POSTBUFFERSIZE, + iterate_post, (void *) con_info); - if (NULL == con_info->postprocessor) + if (NULL == con_info->postprocessor) { - free (con_info); + free (con_info); return MHD_NO; } nr_of_uploading_clients++; - + con_info->connectiontype = POST; con_info->answercode = MHD_HTTP_OK; con_info->answerstring = completepage; - } - else con_info->connectiontype = GET; + } + else + con_info->connectiontype = GET; + + *con_cls = (void *) con_info; - *con_cls = (void*) con_info; - return MHD_YES; } - if (0 == strcmp (method, "GET")) + if (0 == strcmp (method, "GET")) { int ret; - char buffer[1024] = {0}; - + char buffer[1024] = { 0 }; + sprintf (buffer, askpage, nr_of_uploading_clients); - return send_page (connection, buffer, MHD_HTTP_OK); - } - - if (0 == strcmp (method, "POST")) + return send_page (connection, buffer, MHD_HTTP_OK); + } + + if (0 == strcmp (method, "POST")) { struct connection_info_struct *con_info = *con_cls; - - if (0 != *upload_data_size) - { - MHD_post_process(con_info->postprocessor, upload_data, *upload_data_size); + + if (0 != *upload_data_size) + { + MHD_post_process (con_info->postprocessor, upload_data, + *upload_data_size); *upload_data_size = 0; - + return MHD_YES; - } - else return send_page (connection, con_info->answerstring, con_info->answercode); - } + } + else + return send_page (connection, con_info->answerstring, + con_info->answercode); + } - return send_page(connection, errorpage, MHD_HTTP_BAD_REQUEST); + return send_page (connection, errorpage, MHD_HTTP_BAD_REQUEST); } int @@ -192,11 +216,13 @@ main () daemon = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY, PORT, NULL, NULL, - &answer_to_connection, NULL, MHD_OPTION_NOTIFY_COMPLETED, - request_completed, NULL, MHD_OPTION_END); - if (NULL == daemon) return 1; + &answer_to_connection, NULL, + MHD_OPTION_NOTIFY_COMPLETED, request_completed, + NULL, MHD_OPTION_END); + if (NULL == daemon) + return 1; - getchar (); + getchar (); MHD_stop_daemon (daemon); diff --git a/doc/examples/tlsauthentication.c b/doc/examples/tlsauthentication.c @@ -33,24 +33,30 @@ get_file_size (const char *filename) return 0; } -char* -load_file (const char* filename) +char * +load_file (const char *filename) { FILE *fp; char *buffer; long size; size = get_file_size (filename); - if (size == 0) return NULL; + if (size == 0) + return NULL; fp = fopen (filename, "rb"); - if (!fp) return NULL; + if (!fp) + return NULL; buffer = malloc (size); - if (!buffer) {fclose (fp); return NULL;} + if (!buffer) + { + fclose (fp); + return NULL; + } if (size != fread (buffer, 1, size, fp)) - { + { free (buffer); buffer = NULL; } @@ -184,22 +190,23 @@ main () cert_pem = load_file (SERVERCERTFILE); if ((key_pem == NULL) || (cert_pem == NULL)) - { - printf ("The key/certificate files could not be read.\n"); - return 1; - } - - daemon = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_SSL, PORT, NULL, NULL, - &answer_to_connection, NULL, - MHD_OPTION_HTTPS_MEM_KEY, key_pem, MHD_OPTION_HTTPS_MEM_CERT, cert_pem, - MHD_OPTION_END); + { + printf ("The key/certificate files could not be read.\n"); + return 1; + } + + daemon = + MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_SSL, PORT, NULL, + NULL, &answer_to_connection, NULL, + MHD_OPTION_HTTPS_MEM_KEY, key_pem, + MHD_OPTION_HTTPS_MEM_CERT, cert_pem, MHD_OPTION_END); if (NULL == daemon) { printf ("%s\n", cert_pem); - + free (key_pem); free (cert_pem); - + return 1; } @@ -208,7 +215,7 @@ main () MHD_stop_daemon (daemon); free (key_pem); free (cert_pem); - + return 0; } @@ -250,4 +257,3 @@ string_to_base64 (const char *message) return tmp; } - diff --git a/src/daemon/connection.c b/src/daemon/connection.c @@ -286,8 +286,9 @@ connection_close_error (struct MHD_Connection *connection) connection->socket_fd = -1; connection->state = MHD_CONNECTION_CLOSED; if (connection->daemon->notify_completed != NULL) - connection->daemon->notify_completed (connection->daemon-> - notify_completed_cls, connection, + connection->daemon->notify_completed (connection-> + daemon->notify_completed_cls, + connection, &connection->client_context, MHD_REQUEST_TERMINATED_WITH_ERROR); } @@ -316,9 +317,9 @@ try_ready_normal_body (struct MHD_Connection *connection) MHD_MIN (response->data_buffer_size, response->total_size - connection->response_write_position)); - if ( (ret == 0) && - (0 != (connection->daemon->options & MHD_USE_SELECT_INTERNALLY)) ) - abort(); /* serious client API violation */ + if ((ret == 0) && + (0 != (connection->daemon->options & MHD_USE_SELECT_INTERNALLY))) + abort (); /* serious client API violation */ if (ret == -1) { /* either error or http 1.0 transfer, close @@ -405,7 +406,7 @@ try_ready_chunked_body (struct MHD_Connection *connection) if (ret > 0xFFFFFF) ret = 0xFFFFFF; SPRINTF (cbuf, "%X\r\n", ret); - cblen = strlen(cbuf); + cblen = strlen (cbuf); EXTRA_CHECK (cblen <= sizeof (cbuf)); memcpy (&connection->write_buffer[sizeof (cbuf) - cblen], cbuf, cblen); memcpy (&connection->write_buffer[sizeof (cbuf) + ret], "\r\n", 2); @@ -454,8 +455,7 @@ add_extra_headers (struct MHD_Connection *connection) MHD_HTTP_HEADER_CONTENT_LENGTH)) { SPRINTF (buf, - "%llu", - (unsigned long long) connection->response->total_size); + "%llu", (unsigned long long) connection->response->total_size); MHD_add_response_header (connection->response, MHD_HTTP_HEADER_CONTENT_LENGTH, buf); } @@ -482,11 +482,11 @@ get_date_string (char *date) time (&t); gmtime_r (&t, &now); SPRINTF (date, - "Date: %3s, %02u %3s %04u %02u:%02u:%02u GMT\r\n", - days[now.tm_wday % 7], - now.tm_mday, - mons[now.tm_mon % 12], - 1900 + now.tm_year, now.tm_hour, now.tm_min, now.tm_sec); + "Date: %3s, %02u %3s %04u %02u:%02u:%02u GMT\r\n", + days[now.tm_wday % 7], + now.tm_mday, + mons[now.tm_mon % 12], + 1900 + now.tm_year, now.tm_hour, now.tm_min, now.tm_sec); } /** @@ -536,10 +536,8 @@ build_header_response (struct MHD_Connection *connection) add_extra_headers (connection); reason_phrase = MHD_get_reason_phrase_for (connection->responseCode); SPRINTF (code, - "%s %u %s\r\n", - MHD_HTTP_VERSION_1_1, - connection->responseCode, - reason_phrase); + "%s %u %s\r\n", + MHD_HTTP_VERSION_1_1, connection->responseCode, reason_phrase); off = strlen (code); /* estimate size */ size = off + 2; /* extra \r\n at the end */ @@ -1033,7 +1031,7 @@ parse_initial_message_line (struct MHD_Connection *connection, char *line) args++; parse_arguments (MHD_GET_ARGUMENT_KIND, connection, args); } - MHD_http_unescape(uri); + MHD_http_unescape (uri); connection->url = uri; if (httpVersion == NULL) connection->version = ""; @@ -1056,7 +1054,7 @@ call_connection_handler (struct MHD_Connection *connection) int instant_retry; unsigned int i; int malformed; - char * buffer_head; + char *buffer_head; if (connection->response != NULL) return; /* already queued a response */ @@ -1069,17 +1067,15 @@ call_connection_handler (struct MHD_Connection *connection) if ((connection->have_chunked_upload == MHD_YES) && (connection->remaining_upload_size == -1)) { - if ((connection->current_chunk_offset == connection->current_chunk_size) && - (connection->current_chunk_offset != 0) && - (available >= 2)) + if ((connection->current_chunk_offset == + connection->current_chunk_size) + && (connection->current_chunk_offset != 0) && (available >= 2)) { /* skip new line at the *end* of a chunk */ i = 0; - if ((buffer_head[i] == '\r') || - (buffer_head[i] == '\n')) + if ((buffer_head[i] == '\r') || (buffer_head[i] == '\n')) i++; /* skip 1st part of line feed */ - if ((buffer_head[i] == '\r') || - (buffer_head[i] == '\n')) + if ((buffer_head[i] == '\r') || (buffer_head[i] == '\n')) i++; /* skip 2nd part of line feed */ if (i == 0) { @@ -1092,7 +1088,7 @@ call_connection_handler (struct MHD_Connection *connection) return; } available -= i; - buffer_head += i; + buffer_head += i; connection->current_chunk_offset = 0; connection->current_chunk_size = 0; } @@ -1116,31 +1112,28 @@ call_connection_handler (struct MHD_Connection *connection) i = 0; while (i < available) { - if ((buffer_head[i] == '\r') || - (buffer_head[i] == '\n')) + if ((buffer_head[i] == '\r') || (buffer_head[i] == '\n')) break; i++; if (i >= 6) break; } - /* take '\n' into account; if '\n' - is the unavailable character, we - will need to wait until we have it - before going further */ - if ( (i+1 >= available) && - ! ( (i == 1) && - (available == 2) && - (buffer_head[0] == '0') ) ) - break; /* need more data... */ + /* take '\n' into account; if '\n' + is the unavailable character, we + will need to wait until we have it + before going further */ + if ((i + 1 >= available) && + !((i == 1) && (available == 2) && (buffer_head[0] == '0'))) + break; /* need more data... */ malformed = (i >= 6); if (!malformed) { buffer_head[i] = '\0'; malformed = - (1 != SSCANF (buffer_head, "%X", - &connection->current_chunk_size)) && - (1 != SSCANF (buffer_head, "%x", - &connection->current_chunk_size)); + (1 != SSCANF (buffer_head, "%X", + &connection->current_chunk_size)) && + (1 != SSCANF (buffer_head, "%x", + &connection->current_chunk_size)); } if (malformed) { @@ -1153,17 +1146,16 @@ call_connection_handler (struct MHD_Connection *connection) return; } i++; - if ((i<available) && - ( (buffer_head[i] == '\r') || - (buffer_head[i] == '\n')) ) + if ((i < available) && + ((buffer_head[i] == '\r') || (buffer_head[i] == '\n'))) i++; /* skip 2nd part of line feed */ - buffer_head += i; - available -= i; + buffer_head += i; + available -= i; connection->current_chunk_offset = 0; if (available > 0) - instant_retry = MHD_YES; + instant_retry = MHD_YES; if (connection->current_chunk_size == 0) { connection->remaining_upload_size = 0; @@ -1179,13 +1171,12 @@ call_connection_handler (struct MHD_Connection *connection) } used = processed; if (MHD_NO == - connection->daemon->default_handler (connection->daemon-> - default_handler_cls, + connection->daemon->default_handler (connection-> + daemon->default_handler_cls, connection, connection->url, connection->method, connection->version, - buffer_head, - &processed, + buffer_head, &processed, &connection->client_context)) { /* serious internal error, close connection */ @@ -1202,7 +1193,7 @@ call_connection_handler (struct MHD_Connection *connection) instant_retry = MHD_NO; /* client did not process everything */ used -= processed; if (connection->have_chunked_upload == MHD_YES) - connection->current_chunk_offset += used; + connection->current_chunk_offset += used; /* dh left "processed" bytes in buffer for next time... */ buffer_head += used; available -= used; @@ -1211,9 +1202,7 @@ call_connection_handler (struct MHD_Connection *connection) } while (instant_retry == MHD_YES); if (available > 0) - memmove(connection->read_buffer, - buffer_head, - available); + memmove (connection->read_buffer, buffer_head, available); connection->read_buffer_offset = available; } @@ -1234,8 +1223,10 @@ do_read (struct MHD_Connection *connection) return MHD_NO; bytes_read = connection->recv_cls (connection, - &connection->read_buffer[connection->read_buffer_offset], - connection->read_buffer_size - connection->read_buffer_offset); + &connection->read_buffer[connection-> + read_buffer_offset], + connection->read_buffer_size - + connection->read_buffer_offset); if (bytes_read < 0) { if (errno == EINTR) @@ -1271,10 +1262,10 @@ do_write (struct MHD_Connection *connection) int ret; ret = connection->send_cls (connection, - &connection->write_buffer - [connection->write_buffer_send_offset], - connection->write_buffer_append_offset - - connection->write_buffer_send_offset); + &connection->write_buffer + [connection->write_buffer_send_offset], + connection->write_buffer_append_offset + - connection->write_buffer_send_offset); if (ret < 0) { @@ -1581,10 +1572,12 @@ MHD_connection_handle_write (struct MHD_Connection *connection) break; case MHD_CONNECTION_CONTINUE_SENDING: ret = connection->send_cls (connection, - &HTTP_100_CONTINUE - [connection->continue_message_write_offset], - strlen (HTTP_100_CONTINUE) - - connection->continue_message_write_offset); + &HTTP_100_CONTINUE + [connection-> + continue_message_write_offset], + strlen (HTTP_100_CONTINUE) - + connection-> + continue_message_write_offset); if (ret < 0) { if (errno == EINTR) @@ -1633,24 +1626,26 @@ MHD_connection_handle_write (struct MHD_Connection *connection) if (connection->daemon->options & MHD_USE_SSL) { ret = MHD__gnutls_record_send (connection->tls_session, - &connection->response->data - [connection-> - response_write_position - - response->data_start], - response->data_size - - (connection->response_write_position - - response->data_start)); + &connection->response->data + [connection->response_write_position + - response->data_start], + response->data_size - + (connection-> + response_write_position - + response->data_start)); } else #endif { ret = connection->send_cls (connection, - &response->data[connection-> - response_write_position - - response->data_start], - response->data_size - - (connection->response_write_position - - response->data_start)); + &response-> + data + [connection->response_write_position + - response->data_start], + response->data_size - + (connection-> + response_write_position - + response->data_start)); } #if DEBUG_SEND_DATA if (ret > 0) @@ -1705,11 +1700,11 @@ MHD_connection_handle_write (struct MHD_Connection *connection) connection_close_error (connection); return MHD_NO; case MHD_TLS_CONNECTION_INIT: - case MHD_TLS_HELLO_REQUEST: - case MHD_TLS_HANDSHAKE_FAILED: - case MHD_TLS_HANDSHAKE_COMPLETE: - EXTRA_CHECK(0); - break; + case MHD_TLS_HELLO_REQUEST: + case MHD_TLS_HANDSHAKE_FAILED: + case MHD_TLS_HANDSHAKE_COMPLETE: + EXTRA_CHECK (0); + break; } break; } @@ -1983,8 +1978,8 @@ MHD_connection_handle_idle (struct MHD_Connection *connection) case MHD_CONNECTION_FOOTERS_SENT: MHD_destroy_response (connection->response); if (connection->daemon->notify_completed != NULL) - connection->daemon->notify_completed (connection->daemon-> - notify_completed_cls, + connection->daemon->notify_completed (connection-> + daemon->notify_completed_cls, connection, &connection->client_context, MHD_REQUEST_TERMINATED_COMPLETED_OK); diff --git a/src/daemon/connection_https.c b/src/daemon/connection_https.c @@ -58,26 +58,26 @@ MHD_get_connection_info (struct MHD_Connection *connection, { #if HTTPS_SUPPORT case MHD_CONNECTION_INFO_CIPHER_ALGO: - return (const union MHD_ConnectionInfo *) &connection-> - tls_session->security_parameters.read_bulk_cipher_algorithm; + return (const union MHD_ConnectionInfo *) &connection->tls_session-> + security_parameters.read_bulk_cipher_algorithm; case MHD_CONNECTION_INFO_KX_ALGO: - return (const union MHD_ConnectionInfo *) &connection-> - tls_session->security_parameters.kx_algorithm; + return (const union MHD_ConnectionInfo *) &connection->tls_session-> + security_parameters.kx_algorithm; case MHD_CONNECTION_INFO_CREDENTIALS_TYPE: - return (const union MHD_ConnectionInfo *) &connection-> - tls_session->key->cred->algorithm; + return (const union MHD_ConnectionInfo *) &connection->tls_session-> + key->cred->algorithm; case MHD_CONNECTION_INFO_MAC_ALGO: - return (const union MHD_ConnectionInfo *) &connection-> - tls_session->security_parameters.read_mac_algorithm; + return (const union MHD_ConnectionInfo *) &connection->tls_session-> + security_parameters.read_mac_algorithm; case MHD_CONNECTION_INFO_COMPRESSION_METHOD: - return (const union MHD_ConnectionInfo *) &connection-> - tls_session->security_parameters.read_compression_algorithm; + return (const union MHD_ConnectionInfo *) &connection->tls_session-> + security_parameters.read_compression_algorithm; case MHD_CONNECTION_INFO_PROTOCOL: - return (const union MHD_ConnectionInfo *) &connection-> - tls_session->security_parameters.version; + return (const union MHD_ConnectionInfo *) &connection->tls_session-> + security_parameters.version; case MHD_CONNECTION_INFO_CERT_TYPE: - return (const union MHD_ConnectionInfo *) &connection-> - tls_session->security_parameters.cert_type; + return (const union MHD_ConnectionInfo *) &connection->tls_session-> + security_parameters.cert_type; #endif default: return NULL; @@ -96,8 +96,7 @@ MHD_get_connection_info (struct MHD_Connection *connection, */ static void MHD_tls_connection_close (struct MHD_Connection *connection, - enum MHD_RequestTerminationCode - termination_code) + enum MHD_RequestTerminationCode termination_code) { MHD__gnutls_bye (connection->tls_session, GNUTLS_SHUT_WR); connection->tls_session->internals.read_eof = 1; @@ -106,8 +105,9 @@ MHD_tls_connection_close (struct MHD_Connection *connection, connection->socket_fd = -1; connection->state = MHD_CONNECTION_CLOSED; if (connection->daemon->notify_completed != NULL) - connection->daemon->notify_completed (connection->daemon-> - notify_completed_cls, connection, + connection->daemon->notify_completed (connection-> + daemon->notify_completed_cls, + connection, &connection->client_context, termination_code); } @@ -136,7 +136,7 @@ MHD_tls_connection_handle_idle (struct MHD_Connection *connection) && (time (NULL) - timeout > connection->last_activity)) { MHD_tls_connection_close (connection, - MHD_REQUEST_TERMINATED_TIMEOUT_REACHED); + MHD_REQUEST_TERMINATED_TIMEOUT_REACHED); return MHD_NO; } switch (connection->state) @@ -147,12 +147,12 @@ MHD_tls_connection_handle_idle (struct MHD_Connection *connection) /* close connection if necessary */ case MHD_CONNECTION_CLOSED: if (connection->socket_fd != -1) - MHD_tls_connection_close (connection, - MHD_REQUEST_TERMINATED_COMPLETED_OK); + MHD_tls_connection_close (connection, + MHD_REQUEST_TERMINATED_COMPLETED_OK); return MHD_NO; case MHD_TLS_HANDSHAKE_FAILED: MHD_tls_connection_close (connection, - MHD_REQUEST_TERMINATED_WITH_ERROR); + MHD_REQUEST_TERMINATED_WITH_ERROR); return MHD_NO; /* some HTTP state */ default: @@ -237,14 +237,14 @@ MHD_tls_connection_handle_read (struct MHD_Connection *connection) "Error: received handshake message out of context\n"); #endif MHD_tls_connection_close (connection, - MHD_REQUEST_TERMINATED_WITH_ERROR); + MHD_REQUEST_TERMINATED_WITH_ERROR); return MHD_NO; } - /* ignore any out of bound change chiper spec messages */ + /* ignore any out of bound change chiper spec messages */ case GNUTLS_CHANGE_CIPHER_SPEC: MHD_tls_connection_close (connection, - MHD_REQUEST_TERMINATED_WITH_ERROR); + MHD_REQUEST_TERMINATED_WITH_ERROR); return MHD_NO; case GNUTLS_ALERT: @@ -269,8 +269,9 @@ MHD_tls_connection_handle_read (struct MHD_Connection *connection) #if HAVE_MESSAGES MHD_DLOG (connection->daemon, "Received TLS alert: %s\n", - MHD__gnutls_alert_get_name ((int) connection->tls_session-> - internals.last_alert)); + MHD__gnutls_alert_get_name ((int) connection-> + tls_session->internals. + last_alert)); #endif return MHD_YES; } @@ -279,7 +280,7 @@ MHD_tls_connection_handle_read (struct MHD_Connection *connection) GNUTLS_AL_FATAL) { MHD_tls_connection_close (connection, - MHD_REQUEST_TERMINATED_WITH_ERROR); + MHD_REQUEST_TERMINATED_WITH_ERROR); return MHD_NO; } /* this should never execute */ @@ -304,11 +305,12 @@ MHD_tls_connection_handle_read (struct MHD_Connection *connection) #if HAVE_MESSAGES MHD_DLOG (connection->daemon, "Error: unrecognized TLS message type: %d, connection state: %s. l: %d, f: %s\n", - msg_type, MHD_state_to_string(connection->state), __LINE__, __FUNCTION__); + msg_type, MHD_state_to_string (connection->state), __LINE__, + __FUNCTION__); #endif /* close connection upon reception of unrecognized message type */ MHD_tls_connection_close (connection, - MHD_REQUEST_TERMINATED_WITH_ERROR); + MHD_REQUEST_TERMINATED_WITH_ERROR); return MHD_NO; } diff --git a/src/daemon/daemon.c b/src/daemon/daemon.c @@ -1,21 +1,21 @@ /* This file is part of libmicrohttpd (C) 2007, 2008 Daniel Pittman and Christian Grothoff - + This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. - + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - + */ /** @@ -67,7 +67,7 @@ #if HTTPS_SUPPORT /** - * Note: code duplication with code in MHD_gnutls_priority.c + * Note: code duplication with code in MHD_gnutls_priority.c * * @return 0 */ @@ -76,11 +76,10 @@ _set_priority (MHD_gtls_priority_st * st, const int *list) { int num = 0; - while ( (list[num] != 0) && - (num < MAX_ALGOS) ) + while ((list[num] != 0) && (num < MAX_ALGOS)) num++; st->num_algorithms = num; - memcpy(st->priority, list, num * sizeof(int)); + memcpy (st->priority, list, num * sizeof (int)); return 0; } @@ -94,12 +93,9 @@ _set_priority (MHD_gtls_priority_st * st, const int *list) * @return number of bytes actually received */ static ssize_t -recv_tls_adapter (struct MHD_Connection* connection, - void *other, - size_t i) +recv_tls_adapter (struct MHD_Connection *connection, void *other, size_t i) { - return MHD__gnutls_record_recv(connection->tls_session, - other, i); + return MHD__gnutls_record_recv (connection->tls_session, other, i); } /** @@ -111,12 +107,10 @@ recv_tls_adapter (struct MHD_Connection* connection, * @return actual number of bytes written */ static ssize_t -send_tls_adapter (struct MHD_Connection* connection, - const void *other, - size_t i) +send_tls_adapter (struct MHD_Connection *connection, + const void *other, size_t i) { - return MHD__gnutls_record_send(connection->tls_session, - other, i); + return MHD__gnutls_record_send (connection->tls_session, other, i); } @@ -140,8 +134,8 @@ MHD_init_daemon_certificate (struct MHD_Daemon *daemon) cert.size = strlen (daemon->https_mem_cert); return MHD__gnutls_certificate_set_x509_key_mem (daemon->x509_cred, - &cert, &key, - GNUTLS_X509_FMT_PEM); + &cert, &key, + GNUTLS_X509_FMT_PEM); } #if HAVE_MESSAGES MHD_DLOG (daemon, "You need to specify a certificate and key location\n"); @@ -150,7 +144,7 @@ MHD_init_daemon_certificate (struct MHD_Daemon *daemon) } /** - * Initialize security aspects of the HTTPS daemon + * Initialize security aspects of the HTTPS daemon * * @return 0 on success */ @@ -160,22 +154,24 @@ MHD_TLS_init (struct MHD_Daemon *daemon) switch (daemon->cred_type) { case MHD_GNUTLS_CRD_ANON: - if ( (0 != MHD__gnutls_anon_allocate_server_credentials (&daemon->anon_cred)) || - (0 != MHD__gnutls_dh_params_init (&daemon->dh_params)) ) - return GNUTLS_E_MEMORY_ERROR; + if ((0 != + MHD__gnutls_anon_allocate_server_credentials (&daemon->anon_cred)) + || (0 != MHD__gnutls_dh_params_init (&daemon->dh_params))) + return GNUTLS_E_MEMORY_ERROR; MHD__gnutls_dh_params_generate2 (daemon->dh_params, 1024); MHD__gnutls_anon_set_server_dh_params (daemon->anon_cred, - daemon->dh_params); + daemon->dh_params); return 0; case MHD_GNUTLS_CRD_CERTIFICATE: - if (0 != MHD__gnutls_certificate_allocate_credentials (&daemon->x509_cred)) + if (0 != + MHD__gnutls_certificate_allocate_credentials (&daemon->x509_cred)) return GNUTLS_E_MEMORY_ERROR; return MHD_init_daemon_certificate (daemon); default: #if HAVE_MESSAGES MHD_DLOG (daemon, "Error: invalid credentials type %d specified.\n", - daemon->cred_type); + daemon->cred_type); #endif return -1; } @@ -257,9 +253,9 @@ MHD_handle_connection (void *data) tv.tv_sec = timeout - (now - con->last_activity); else tv.tv_sec = 0; - if ( (con->state == MHD_CONNECTION_NORMAL_BODY_UNREADY) || - (con->state == MHD_CONNECTION_CHUNKED_BODY_UNREADY) ) - timeout = 1; /* do not block */ + if ((con->state == MHD_CONNECTION_NORMAL_BODY_UNREADY) || + (con->state == MHD_CONNECTION_CHUNKED_BODY_UNREADY)) + timeout = 1; /* do not block */ num_ready = SELECT (max + 1, &rs, &ws, &es, (timeout != 0) ? &tv : NULL); if (num_ready < 0) @@ -304,13 +300,11 @@ MHD_handle_connection (void *data) * @return number of bytes actually received */ static ssize_t -recv_param_adapter (struct MHD_Connection * connection, - void *other, - size_t i) +recv_param_adapter (struct MHD_Connection *connection, void *other, size_t i) { if (connection->socket_fd == -1) return -1; - return RECV(connection->socket_fd, other, i, MSG_NOSIGNAL); + return RECV (connection->socket_fd, other, i, MSG_NOSIGNAL); } /** @@ -323,12 +317,11 @@ recv_param_adapter (struct MHD_Connection * connection, */ static ssize_t send_param_adapter (struct MHD_Connection *connection, - const void *other, - size_t i) + const void *other, size_t i) { if (connection->socket_fd == -1) return -1; - return SEND(connection->socket_fd, other, i, MSG_NOSIGNAL); + return SEND (connection->socket_fd, other, i, MSG_NOSIGNAL); } /** @@ -490,37 +483,41 @@ MHD_accept_connection (struct MHD_Daemon *daemon) connection->recv_cls = &recv_tls_adapter; connection->send_cls = &send_tls_adapter; connection->state = MHD_TLS_CONNECTION_INIT; - MHD_set_https_calbacks (connection); + MHD_set_https_calbacks (connection); MHD__gnutls_init (&connection->tls_session, GNUTLS_SERVER); - MHD__gnutls_priority_set (connection->tls_session, connection->daemon->priority_cache); + MHD__gnutls_priority_set (connection->tls_session, + connection->daemon->priority_cache); switch (connection->daemon->cred_type) - { - /* set needed credentials for certificate authentication. */ - case MHD_GNUTLS_CRD_CERTIFICATE: - MHD__gnutls_credentials_set (connection->tls_session, - MHD_GNUTLS_CRD_CERTIFICATE, - connection->daemon->x509_cred); - break; - case MHD_GNUTLS_CRD_ANON: - /* set needed credentials for anonymous authentication. */ - MHD__gnutls_credentials_set (connection->tls_session, MHD_GNUTLS_CRD_ANON, - connection->daemon->anon_cred); - MHD__gnutls_dh_set_prime_bits (connection->tls_session, 1024); - break; - default: + { + /* set needed credentials for certificate authentication. */ + case MHD_GNUTLS_CRD_CERTIFICATE: + MHD__gnutls_credentials_set (connection->tls_session, + MHD_GNUTLS_CRD_CERTIFICATE, + connection->daemon->x509_cred); + break; + case MHD_GNUTLS_CRD_ANON: + /* set needed credentials for anonymous authentication. */ + MHD__gnutls_credentials_set (connection->tls_session, + MHD_GNUTLS_CRD_ANON, + connection->daemon->anon_cred); + MHD__gnutls_dh_set_prime_bits (connection->tls_session, 1024); + break; + default: #if HAVE_MESSAGES - MHD_DLOG (connection->daemon, - "Failed to setup TLS credentials: unknown credential type %d\n", - connection->daemon->cred_type); + MHD_DLOG (connection->daemon, + "Failed to setup TLS credentials: unknown credential type %d\n", + connection->daemon->cred_type); #endif - abort(); - } + abort (); + } MHD__gnutls_transport_set_ptr (connection->tls_session, - (MHD_gnutls_transport_ptr_t) connection); - MHD__gnutls_transport_set_pull_function(connection->tls_session, - (MHD_gtls_pull_func) &recv_param_adapter); - MHD__gnutls_transport_set_push_function(connection->tls_session, - (MHD_gtls_push_func) &send_param_adapter); + (MHD_gnutls_transport_ptr_t) connection); + MHD__gnutls_transport_set_pull_function (connection->tls_session, + (MHD_gtls_pull_func) & + recv_param_adapter); + MHD__gnutls_transport_set_push_function (connection->tls_session, + (MHD_gtls_push_func) & + send_param_adapter); } #endif @@ -528,8 +525,7 @@ MHD_accept_connection (struct MHD_Daemon *daemon) if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) { res_thread_create = pthread_create (&connection->pid, NULL, - &MHD_handle_connection, - connection); + &MHD_handle_connection, connection); if (res_thread_create != 0) { #if HAVE_MESSAGES @@ -542,7 +538,7 @@ MHD_accept_connection (struct MHD_Daemon *daemon) free (connection); return MHD_NO; } - } + } connection->next = daemon->connections; daemon->connections = connection; daemon->max_connections--; @@ -565,35 +561,34 @@ MHD_cleanup_connections (struct MHD_Daemon *daemon) prev = NULL; while (pos != NULL) { - if ( (pos->socket_fd == -1) || - ( ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) && - (daemon->shutdown) && - (pos->socket_fd != -1) ) ) ) - { + if ((pos->socket_fd == -1) || + (((0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) && + (daemon->shutdown) && (pos->socket_fd != -1)))) + { if (prev == NULL) daemon->connections = pos->next; else - prev->next = pos->next; - if (0 != (pos->daemon->options & MHD_USE_THREAD_PER_CONNECTION)) - { - pthread_kill (pos->pid, SIGALRM); - pthread_join (pos->pid, &unused); - } - MHD_destroy_response (pos->response); - MHD_pool_destroy (pos->pool); + prev->next = pos->next; + if (0 != (pos->daemon->options & MHD_USE_THREAD_PER_CONNECTION)) + { + pthread_kill (pos->pid, SIGALRM); + pthread_join (pos->pid, &unused); + } + MHD_destroy_response (pos->response); + MHD_pool_destroy (pos->pool); #if HTTPS_SUPPORT - if (pos->tls_session != NULL) - MHD__gnutls_deinit (pos->tls_session); + if (pos->tls_session != NULL) + MHD__gnutls_deinit (pos->tls_session); #endif - free (pos->addr); - free (pos); - daemon->max_connections++; - if (prev == NULL) + free (pos->addr); + free (pos); + daemon->max_connections++; + if (prev == NULL) pos = daemon->connections; else pos = prev->next; - continue; - } + continue; + } prev = pos; pos = pos->next; } @@ -946,9 +941,9 @@ MHD_start_daemon_va (unsigned int options, #else { #if HAVE_MESSAGES - FPRINTF (stderr, "AF_INET6 not supported\n"); + FPRINTF (stderr, "AF_INET6 not supported\n"); #endif - return NULL; + return NULL; } #endif else @@ -1026,8 +1021,7 @@ MHD_start_daemon_va (unsigned int options, #if HTTPS_SUPPORT /* initialize HTTPS daemon certificate aspects & send / recv functions */ - if ( (0 != (options & MHD_USE_SSL)) && - (0 != MHD_TLS_init (retVal)) ) + if ((0 != (options & MHD_USE_SSL)) && (0 != MHD_TLS_init (retVal))) { #if HAVE_MESSAGES MHD_DLOG (retVal, "Failed to initialize TLS support\n"); @@ -1073,7 +1067,7 @@ MHD_stop_daemon (struct MHD_Daemon *daemon) #endif #endif CLOSE (fd); - if ((0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) || + if ((0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) || (0 != (daemon->options & MHD_USE_SELECT_INTERNALLY))) { pthread_kill (daemon->pid, SIGALRM); @@ -1128,9 +1122,9 @@ MHD_stop_daemon (struct MHD_Daemon *daemon) * @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, ...) +const union MHD_DaemonInfo * +MHD_get_daemon_info (struct MHD_Daemon *daemon, + enum MHD_DaemonInfoType infoType, ...) { return NULL; } diff --git a/src/daemon/https/gnutls.h b/src/daemon/https/gnutls.h @@ -211,32 +211,36 @@ extern "C" } MHD_gnutls_params_st; typedef int MHD_gnutls_params_function (MHD_gtls_session_t, - MHD_gnutls_params_type_t, - MHD_gnutls_params_st *); + MHD_gnutls_params_type_t, + MHD_gnutls_params_st *); /* internal functions */ int MHD__gnutls_global_init (void); void MHD__gnutls_global_deinit (void); int MHD__gnutls_init (MHD_gtls_session_t * session, - MHD_gnutls_connection_end_t con_end); + MHD_gnutls_connection_end_t con_end); void MHD__gnutls_deinit (MHD_gtls_session_t session); - int MHD__gnutls_bye (MHD_gtls_session_t session, MHD_gnutls_close_request_t how); + int MHD__gnutls_bye (MHD_gtls_session_t session, + MHD_gnutls_close_request_t how); int MHD__gnutls_handshake (MHD_gtls_session_t session); int MHD__gnutls_rehandshake (MHD_gtls_session_t session); int MHD_gtls_handshake_client (MHD_gtls_session_t session); - MHD_gnutls_alert_description_t MHD_gnutls_alert_get (MHD_gtls_session_t session); + MHD_gnutls_alert_description_t MHD_gnutls_alert_get (MHD_gtls_session_t + session); int MHD__gnutls_alert_send (MHD_gtls_session_t session, - MHD_gnutls_alert_level_t level, - MHD_gnutls_alert_description_t desc); - int MHD__gnutls_alert_send_appropriate (MHD_gtls_session_t session, int err); - const char *MHD__gnutls_alert_get_name (MHD_gnutls_alert_description_t alert); - - enum MHD_GNUTLS_CompressionMethod MHD_gtls_compression_get (MHD_gtls_session_t - session); + MHD_gnutls_alert_level_t level, + MHD_gnutls_alert_description_t desc); + int MHD__gnutls_alert_send_appropriate (MHD_gtls_session_t session, + int err); + const char *MHD__gnutls_alert_get_name (MHD_gnutls_alert_description_t + alert); + + enum MHD_GNUTLS_CompressionMethod + MHD_gtls_compression_get (MHD_gtls_session_t session); // enum MHD_GNUTLS_CipherAlgorithm MHD_gnutls_cipher_get (MHD_gtls_session_t session); // enum MHD_GNUTLS_KeyExchangeAlgorithm MHD_gnutls_kx_get (MHD_gtls_session_t session); // enum MHD_GNUTLS_HashAlgorithm MHD_gnutls_mac_get (MHD_gtls_session_t session); @@ -244,23 +248,23 @@ extern "C" // session); size_t MHD__gnutls_cipher_get_key_size (enum MHD_GNUTLS_CipherAlgorithm - algorithm); + algorithm); size_t MHD__gnutls_mac_get_key_size (enum MHD_GNUTLS_HashAlgorithm - algorithm); + algorithm); /* the name of the specified algorithms */ const char *MHD__gnutls_cipher_get_name (enum MHD_GNUTLS_CipherAlgorithm - algorithm); + algorithm); const char *MHD__gnutls_mac_get_name (enum MHD_GNUTLS_HashAlgorithm - algorithm); + algorithm); const char *MHD_gtls_compression_get_name (enum - MHD_GNUTLS_CompressionMethod - algorithm); + MHD_GNUTLS_CompressionMethod + algorithm); const char *MHD__gnutls_kx_get_name (enum MHD_GNUTLS_KeyExchangeAlgorithm - algorithm); + algorithm); const char *MHD__gnutls_certificate_type_get_name (enum - MHD_GNUTLS_CertificateType - type); + MHD_GNUTLS_CertificateType + type); enum MHD_GNUTLS_HashAlgorithm MHD_gtls_mac_get_id (const char *name); enum MHD_GNUTLS_CompressionMethod MHD_gtls_compression_get_id (const char @@ -292,9 +296,9 @@ extern "C" * Record layer functions. */ ssize_t MHD__gnutls_record_send (MHD_gtls_session_t session, - const void *data, size_t sizeofdata); + const void *data, size_t sizeofdata); ssize_t MHD__gnutls_record_recv (MHD_gtls_session_t session, void *data, - size_t sizeofdata); + size_t sizeofdata); /* provides extra compatibility */ void MHD_gtls_record_disable_padding (MHD_gtls_session_t session); @@ -303,19 +307,19 @@ extern "C" int MHD__gnutls_record_get_direction (MHD_gtls_session_t session); size_t MHD__gnutls_record_get_max_size (MHD_gtls_session_t session); ssize_t MHD__gnutls_record_set_max_size (MHD_gtls_session_t session, - size_t size); + size_t size); int MHD__gnutls_prf (MHD_gtls_session_t session, - size_t label_size, const char *label, - int server_random_first, - size_t extra_size, const char *extra, - size_t outsize, char *out); + size_t label_size, const char *label, + int server_random_first, + size_t extra_size, const char *extra, + size_t outsize, char *out); int MHD__gnutls_prf_raw (MHD_gtls_session_t session, - size_t label_size, const char *label, - size_t seed_size, const char *seed, - size_t outsize, char *out); + size_t label_size, const char *label, + size_t seed_size, const char *seed, + size_t outsize, char *out); /* * TLS Extensions @@ -326,12 +330,12 @@ extern "C" } MHD_gnutls_server_name_type_t; int MHD__gnutls_server_name_set (MHD_gtls_session_t session, - MHD_gnutls_server_name_type_t type, - const void *name, size_t name_length); + MHD_gnutls_server_name_type_t type, + const void *name, size_t name_length); int MHD__gnutls_server_name_get (MHD_gtls_session_t session, - void *data, size_t * data_length, - unsigned int *type, unsigned int indx); + void *data, size_t * data_length, + unsigned int *type, unsigned int indx); /* Opaque PRF Input * http://tools.ietf.org/id/draft-rescorla-tls-opaque-prf-input-00.txt @@ -342,10 +346,11 @@ extern "C" size_t len, unsigned char *data); typedef int (*MHD_gnutls_oprfi_callback_func) (MHD_gtls_session_t session, - void *userdata, - size_t oprfi_len, - const unsigned char *in_oprfi, - unsigned char *out_oprfi); + void *userdata, + size_t oprfi_len, + const unsigned char + *in_oprfi, + unsigned char *out_oprfi); void MHD_gtls_oprfi_enable_server (MHD_gtls_session_t session, @@ -362,32 +367,35 @@ extern "C" (MHD_gnutls_supplemental_data_format_type_t type); int MHD__gnutls_cipher_set_priority (MHD_gtls_session_t session, - const int *list); + const int *list); int MHD__gnutls_mac_set_priority (MHD_gtls_session_t session, - const int *list); + const int *list); int MHD__gnutls_compression_set_priority (MHD_gtls_session_t session, - const int *list); + const int *list); int MHD__gnutls_kx_set_priority (MHD_gtls_session_t session, - const int *list); + const int *list); int MHD__gnutls_protocol_set_priority (MHD_gtls_session_t session, - const int *list); + const int *list); int MHD__gnutls_certificate_type_set_priority (MHD_gtls_session_t session, - const int *list); + const int *list); - int MHD_tls_set_default_priority (MHD_gnutls_priority_t *, const char *priority, + int MHD_tls_set_default_priority (MHD_gnutls_priority_t *, + const char *priority, const char **err_pos); void MHD__gnutls_priority_deinit (MHD_gnutls_priority_t); - int MHD__gnutls_priority_set (MHD_gtls_session_t session, MHD_gnutls_priority_t); + int MHD__gnutls_priority_set (MHD_gtls_session_t session, + MHD_gnutls_priority_t); int MHD__gnutls_priority_set_direct (MHD_gtls_session_t session, - const char *priority, - const char **err_pos); + const char *priority, + const char **err_pos); /* get the currently used protocol version */ - enum MHD_GNUTLS_Protocol 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 (enum MHD_GNUTLS_Protocol version); + const char *MHD__gnutls_protocol_get_name (enum MHD_GNUTLS_Protocol + version); /* * get/set session @@ -412,13 +420,14 @@ extern "C" int MHD_gtls_session_is_resumed (MHD_gtls_session_t session); - typedef int (*MHD_gnutls_handshake_post_client_hello_func) (MHD_gtls_session_t); + typedef + int (*MHD_gnutls_handshake_post_client_hello_func) (MHD_gtls_session_t); void MHD__gnutls_handshake_set_post_client_hello_function (MHD_gtls_session_t, - MHD_gnutls_handshake_post_client_hello_func); + MHD_gnutls_handshake_post_client_hello_func); - void MHD__gnutls_handshake_set_max_packet_length (MHD_gtls_session_t session, - size_t max); + void MHD__gnutls_handshake_set_max_packet_length (MHD_gtls_session_t + session, size_t max); /* * Functions for setting/clearing credentials @@ -429,8 +438,8 @@ extern "C" * cred is a structure defined by the kx algorithm */ int MHD__gnutls_credentials_set (MHD_gtls_session_t session, - enum MHD_GNUTLS_CredentialsType type, - void *cred); + enum MHD_GNUTLS_CredentialsType type, + void *cred); /* Credential structures - used in MHD__gnutls_credentials_set(); */ struct MHD_gtls_certificate_credentials_st; @@ -453,12 +462,13 @@ extern "C" void MHD__gnutls_anon_set_server_dh_params (MHD_gtls_anon_server_credentials_t - res, - MHD_gtls_dh_params_t dh_params); + res, + MHD_gtls_dh_params_t dh_params); void MHD__gnutls_anon_set_server_params_function - (MHD_gtls_anon_server_credentials_t res, MHD_gnutls_params_function * func); + (MHD_gtls_anon_server_credentials_t res, + MHD_gnutls_params_function * func); void MHD__gnutls_anon_free_client_credentials @@ -468,10 +478,10 @@ extern "C" (MHD_gtls_anon_client_credentials_t * sc); void MHD__gnutls_certificate_free_credentials (MHD_gtls_cert_credentials_t - sc); + sc); int MHD__gnutls_certificate_allocate_credentials (MHD_gtls_cert_credentials_t - * res); + * res); void MHD__gnutls_certificate_free_keys (MHD_gtls_cert_credentials_t sc); void MHD__gnutls_certificate_free_cas (MHD_gtls_cert_credentials_t sc); @@ -479,50 +489,60 @@ extern "C" void MHD__gnutls_certificate_free_crls (MHD_gtls_cert_credentials_t sc); void MHD__gnutls_certificate_set_dh_params (MHD_gtls_cert_credentials_t res, - MHD_gtls_dh_params_t dh_params); + MHD_gtls_dh_params_t dh_params); void MHD__gnutls_certificate_set_rsa_export_params (MHD_gtls_cert_credentials_t - res, - MHD_gtls_rsa_params_t - rsa_params); + res, + MHD_gtls_rsa_params_t + rsa_params); void MHD__gnutls_certificate_set_verify_flags (MHD_gtls_cert_credentials_t - res, unsigned int flags); + res, unsigned int flags); void MHD__gnutls_certificate_set_verify_limits (MHD_gtls_cert_credentials_t - res, unsigned int max_bits, - unsigned int max_depth); + res, unsigned int max_bits, + unsigned int max_depth); int MHD__gnutls_certificate_set_x509_trust_file (MHD_gtls_cert_credentials_t - res, const char *CAFILE, - MHD_gnutls_x509_crt_fmt_t type); + res, const char *CAFILE, + MHD_gnutls_x509_crt_fmt_t + type); int MHD__gnutls_certificate_set_x509_trust_mem (MHD_gtls_cert_credentials_t - res, - const MHD_gnutls_datum_t * CA, - MHD_gnutls_x509_crt_fmt_t type); + res, + const MHD_gnutls_datum_t * + CA, + MHD_gnutls_x509_crt_fmt_t + type); int MHD__gnutls_certificate_set_x509_crl_file (MHD_gtls_cert_credentials_t - res, const char *crlfile, - MHD_gnutls_x509_crt_fmt_t type); + res, const char *crlfile, + MHD_gnutls_x509_crt_fmt_t + type); int MHD__gnutls_certificate_set_x509_crl_mem (MHD_gtls_cert_credentials_t - res, - const MHD_gnutls_datum_t * CRL, - MHD_gnutls_x509_crt_fmt_t type); + res, + const MHD_gnutls_datum_t * + CRL, + MHD_gnutls_x509_crt_fmt_t + type); /* * CERTFILE is an x509 certificate in PEM form. * KEYFILE is a pkcs-1 private key in PEM form (for RSA keys). */ int MHD__gnutls_certificate_set_x509_key_file (MHD_gtls_cert_credentials_t - res, const char *CERTFILE, - const char *KEYFILE, - MHD_gnutls_x509_crt_fmt_t type); + res, const char *CERTFILE, + const char *KEYFILE, + MHD_gnutls_x509_crt_fmt_t + type); int MHD__gnutls_certificate_set_x509_key_mem (MHD_gtls_cert_credentials_t - res, - const MHD_gnutls_datum_t * CERT, - const MHD_gnutls_datum_t * KEY, - MHD_gnutls_x509_crt_fmt_t type); + res, + const MHD_gnutls_datum_t * + CERT, + const MHD_gnutls_datum_t * + KEY, + MHD_gnutls_x509_crt_fmt_t + type); void MHD__gnutls_certificate_send_x509_rdn_sequence (MHD_gtls_session_t - session, int status); + session, int status); /* * New functions to allow setting already parsed X.509 stuff. @@ -558,7 +578,8 @@ extern "C" typedef void *(*MHD_gnutls_realloc_function) (void *, size_t); extern void - MHD_gtls_global_set_mem_functions (MHD_gnutls_alloc_function gt_alloc_func, + MHD_gtls_global_set_mem_functions (MHD_gnutls_alloc_function + gt_alloc_func, MHD_gnutls_alloc_function gt_secure_alloc_func, MHD_gnutls_is_secure_function @@ -586,14 +607,14 @@ extern "C" int MHD__gnutls_dh_params_init (MHD_gtls_dh_params_t * dh_params); void MHD__gnutls_dh_params_deinit (MHD_gtls_dh_params_t dh_params); int MHD__gnutls_dh_params_generate2 (MHD_gtls_dh_params_t params, - unsigned int bits); + unsigned int bits); /* RSA params */ int MHD__gnutls_rsa_params_init (MHD_gtls_rsa_params_t * rsa_params); void MHD__gnutls_rsa_params_deinit (MHD_gtls_rsa_params_t rsa_params); int MHD__gnutls_rsa_params_generate2 (MHD_gtls_rsa_params_t params, - unsigned int bits); + unsigned int bits); /* @@ -601,21 +622,21 @@ extern "C" */ typedef ssize_t (*MHD_gtls_pull_func) (MHD_gnutls_transport_ptr_t, void *, size_t); - typedef ssize_t (*MHD_gtls_push_func) (MHD_gnutls_transport_ptr_t, const void *, - size_t); + typedef ssize_t (*MHD_gtls_push_func) (MHD_gnutls_transport_ptr_t, + const void *, size_t); void MHD__gnutls_transport_set_ptr (MHD_gtls_session_t session, - MHD_gnutls_transport_ptr_t ptr); + MHD_gnutls_transport_ptr_t ptr); void MHD__gnutls_transport_set_ptr2 (MHD_gtls_session_t session, - MHD_gnutls_transport_ptr_t recv_ptr, - MHD_gnutls_transport_ptr_t send_ptr); + MHD_gnutls_transport_ptr_t recv_ptr, + MHD_gnutls_transport_ptr_t send_ptr); void MHD__gnutls_transport_set_lowat (MHD_gtls_session_t session, int num); void MHD__gnutls_transport_set_push_function (MHD_gtls_session_t session, - MHD_gtls_push_func push_func); + MHD_gtls_push_func push_func); void MHD__gnutls_transport_set_pull_function (MHD_gtls_session_t session, - MHD_gtls_pull_func pull_func); + MHD_gtls_pull_func pull_func); void MHD__gnutls_transport_set_errno (MHD_gtls_session_t session, int err); void MHD__gnutls_transport_set_global_errno (int err); @@ -630,8 +651,8 @@ extern "C" * this function returns the hash of the given data. */ int MHD__gnutls_fingerprint (enum MHD_GNUTLS_HashAlgorithm algo, - const MHD_gnutls_datum_t * data, void *result, - size_t * result_size); + const MHD_gnutls_datum_t * data, void *result, + size_t * result_size); typedef enum MHD_gnutls_x509_subject_alt_name_t { @@ -664,21 +685,19 @@ extern "C" unsigned int deinit_all; /* if non zero all keys will be deinited */ } MHD_gnutls_retr_st; - typedef int MHD_gnutls_certificate_client_retrieve_function (MHD_gtls_session_t, - const - MHD_gnutls_datum_t * - req_ca_rdn, - int nreqs, - const - enum - MHD_GNUTLS_PublicKeyAlgorithm - *pk_algos, - int - pk_algos_length, - MHD_gnutls_retr_st *); - - typedef int MHD_gnutls_certificate_server_retrieve_function (MHD_gtls_session_t, - MHD_gnutls_retr_st *); + typedef int + MHD_gnutls_certificate_client_retrieve_function (MHD_gtls_session_t, + const MHD_gnutls_datum_t + * req_ca_rdn, int nreqs, + const enum + MHD_GNUTLS_PublicKeyAlgorithm + *pk_algos, + int pk_algos_length, + MHD_gnutls_retr_st *); + + typedef int + MHD_gnutls_certificate_server_retrieve_function (MHD_gtls_session_t, + MHD_gnutls_retr_st *); /* * Functions that allow auth_info_t structures handling @@ -694,16 +713,16 @@ extern "C" * DH */ void MHD__gnutls_dh_set_prime_bits (MHD_gtls_session_t session, - unsigned int bits); + unsigned int bits); int MHD__gnutls_dh_get_secret_bits (MHD_gtls_session_t session); int MHD__gnutls_dh_get_peers_public_bits (MHD_gtls_session_t session); int MHD__gnutls_dh_get_prime_bits (MHD_gtls_session_t session); int MHD__gnutls_dh_get_group (MHD_gtls_session_t session, - MHD_gnutls_datum_t * raw_gen, - MHD_gnutls_datum_t * raw_prime); + MHD_gnutls_datum_t * raw_gen, + MHD_gnutls_datum_t * raw_prime); int MHD__gnutls_dh_get_pubkey (MHD_gtls_session_t session, - MHD_gnutls_datum_t * raw_key); + MHD_gnutls_datum_t * raw_key); /* * RSA @@ -715,17 +734,18 @@ extern "C" /* External signing callback. Experimental. */ typedef int (*MHD_gnutls_sign_func) (MHD_gtls_session_t session, - void *userdata, - enum MHD_GNUTLS_CertificateType cert_type, - const MHD_gnutls_datum_t * cert, - const MHD_gnutls_datum_t * hash, - MHD_gnutls_datum_t * signature); + void *userdata, + enum MHD_GNUTLS_CertificateType + cert_type, + const MHD_gnutls_datum_t * cert, + const MHD_gnutls_datum_t * hash, + MHD_gnutls_datum_t * signature); void MHD_gtls_sign_callback_set (MHD_gtls_session_t session, MHD_gnutls_sign_func sign_func, void *userdata); - MHD_gnutls_sign_func MHD_gtls_sign_callback_get (MHD_gtls_session_t session, - void **userdata); + MHD_gnutls_sign_func MHD_gtls_sign_callback_get (MHD_gtls_session_t session, + void **userdata); /* These are set on the credentials structure. */ @@ -742,11 +762,11 @@ extern "C" /* get data from the session */ const MHD_gnutls_datum_t *MHD_gtls_certificate_get_peers (MHD_gtls_session_t - session, - unsigned int - *list_size); + session, + unsigned int + *list_size); const MHD_gnutls_datum_t *MHD_gtls_certificate_get_ours (MHD_gtls_session_t - session); + session); time_t MHD_gtls_certificate_activation_time_peers (MHD_gtls_session_t session); @@ -762,8 +782,8 @@ extern "C" int MHD_gtls_certificate_verify_peers (MHD_gtls_session_t session); int MHD_gtls_pem_base64_encode (const char *msg, - const MHD_gnutls_datum_t * data, char *result, - size_t * result_size); + const MHD_gnutls_datum_t * data, + char *result, size_t * result_size); int MHD_gtls_pem_base64_decode (const char *header, const MHD_gnutls_datum_t * b64_data, unsigned char *result, diff --git a/src/daemon/https/lgl/des.c b/src/daemon/https/lgl/des.c @@ -543,7 +543,8 @@ MHD_gl_des_makekey (MHD_gl_des_ctx * ctx, const char *key, size_t keylen) } void -MHD_gl_des_ecb_crypt (MHD_gl_des_ctx * ctx, const char *_from, char *_to, int mode) +MHD_gl_des_ecb_crypt (MHD_gl_des_ctx * ctx, const char *_from, char *_to, + int mode) { const unsigned char *from = (const unsigned char *) _from; unsigned char *to = (unsigned char *) _to; @@ -565,7 +566,8 @@ READ_64BIT_DATA (from, left, right) FINAL_PERMUTATION (right, work, left) WRITE_64BIT_DATA (to, right, left)} void -MHD_gl_3des_set2keys (MHD_gl_3des_ctx * ctx, const char *key1, const char *key2) +MHD_gl_3des_set2keys (MHD_gl_3des_ctx * ctx, const char *key1, + const char *key2) { int i; @@ -590,7 +592,7 @@ MHD_gl_3des_set2keys (MHD_gl_3des_ctx * ctx, const char *key1, const char *key2) void MHD_gl_3des_set3keys (MHD_gl_3des_ctx * ctx, const char *key1, - const char *key2, const char *key3) + const char *key2, const char *key3) { int i; @@ -612,7 +614,8 @@ MHD_gl_3des_set3keys (MHD_gl_3des_ctx * ctx, const char *key1, } void -MHD_gl_3des_ecb_crypt (MHD_gl_3des_ctx * ctx, const char *_from, char *_to, int mode) +MHD_gl_3des_ecb_crypt (MHD_gl_3des_ctx * ctx, const char *_from, char *_to, + int mode) { const unsigned char *from = (const unsigned char *) _from; unsigned char *to = (unsigned char *) _to; @@ -658,5 +661,6 @@ MHD_gl_3des_makekey (MHD_gl_3des_ctx * ctx, const char *key, size_t keylen) MHD_gl_3des_set3keys (ctx, key, key + 8, key + 16); return !(MHD_gl_des_is_weak_key (key) - || MHD_gl_des_is_weak_key (key + 8) || MHD_gl_des_is_weak_key (key + 16)); + || MHD_gl_des_is_weak_key (key + 8) + || MHD_gl_des_is_weak_key (key + 16)); } diff --git a/src/daemon/https/lgl/des.h b/src/daemon/https/lgl/des.h @@ -62,12 +62,14 @@ extern void MHD_gl_des_setkey (MHD_gl_des_ctx * ctx, const char *key); /* Fill a DES context CTX with subkeys calculated from 64bit KEY, with * weak key checking. Does not check parity bits, but simply ignore * them. */ -extern bool MHD_gl_des_makekey (MHD_gl_des_ctx * ctx, const char *key, size_t keylen); +extern bool MHD_gl_des_makekey (MHD_gl_des_ctx * ctx, const char *key, + size_t keylen); /* Electronic Codebook Mode DES encryption/decryption of data * according to 'mode'. */ extern void -MHD_gl_des_ecb_crypt (MHD_gl_des_ctx * ctx, const char *from, char *to, int mode); +MHD_gl_des_ecb_crypt (MHD_gl_des_ctx * ctx, const char *from, char *to, + int mode); #define MHD_gl_des_ecb_encrypt(ctx, from, to) MHD_gl_des_ecb_crypt(ctx, from, to, 0) #define MHD_gl_des_ecb_decrypt(ctx, from, to) MHD_gl_des_ecb_crypt(ctx, from, to, 1) @@ -80,7 +82,8 @@ MHD_gl_des_ecb_crypt (MHD_gl_des_ctx * ctx, const char *from, char *to, int mode * 64bit keys in KEY1 and KEY2. Does not check the parity bits of the * keys, but simply ignore them. Does not check for weak keys. */ extern void -MHD_gl_3des_set2keys (MHD_gl_3des_ctx * ctx, const char *key1, const char *key2); +MHD_gl_3des_set2keys (MHD_gl_3des_ctx * ctx, const char *key1, + const char *key2); /* * Fill a Triple-DES context CTX with subkeys calculated from three @@ -89,7 +92,7 @@ MHD_gl_3des_set2keys (MHD_gl_3des_ctx * ctx, const char *key1, const char *key2) * keys. */ extern void MHD_gl_3des_set3keys (MHD_gl_3des_ctx * ctx, - const char *key1, const char *key2, const char *key3); + const char *key1, const char *key2, const char *key3); /* Fill a Triple-DES context CTX with subkeys calculated from three * concatenated 64bit keys in KEY, with weak key checking. Does not @@ -101,7 +104,8 @@ MHD_gl_3des_makekey (MHD_gl_3des_ctx * ctx, const char *key, size_t keylen); * according to 'mode'. Sometimes this mode is named 'EDE' mode * (Encryption-Decryption-Encryption). */ extern void -MHD_gl_3des_ecb_crypt (MHD_gl_3des_ctx * ctx, const char *from, char *to, int mode); +MHD_gl_3des_ecb_crypt (MHD_gl_3des_ctx * ctx, const char *from, char *to, + int mode); #define MHD_gl_3des_ecb_encrypt(ctx, from, to) MHD_gl_3des_ecb_crypt(ctx,from,to,0) #define MHD_gl_3des_ecb_decrypt(ctx, from, to) MHD_gl_3des_ecb_crypt(ctx,from,to,1) diff --git a/src/daemon/https/lgl/gc-gnulib.c b/src/daemon/https/lgl/gc-gnulib.c @@ -161,9 +161,9 @@ MHD_gc_random (char *data, size_t datalen) /* Memory allocation. */ void MHD_gc_set_allocators (MHD_gc_malloc_t func_malloc, - MHD_gc_malloc_t secure_malloc, - MHD_gc_secure_check_t secure_check, - MHD_gc_realloc_t func_realloc, MHD_gc_free_t func_free) + MHD_gc_malloc_t secure_malloc, + MHD_gc_secure_check_t secure_check, + MHD_gc_realloc_t func_realloc, MHD_gc_free_t func_free) { return; } @@ -193,7 +193,7 @@ typedef struct _MHD_gc_cipher_ctx Gc_rc MHD_gc_cipher_open (Gc_cipher alg, - Gc_cipher_mode mode, MHD_gc_cipher_handle * outhandle) + Gc_cipher_mode mode, MHD_gc_cipher_handle * outhandle) { _MHD_gc_cipher_ctx *ctx; Gc_rc rc = GC_OK; @@ -277,7 +277,8 @@ MHD_gc_cipher_open (Gc_cipher alg, } Gc_rc -MHD_gc_cipher_setkey (MHD_gc_cipher_handle handle, size_t keylen, const char *key) +MHD_gc_cipher_setkey (MHD_gc_cipher_handle handle, size_t keylen, + const char *key) { _MHD_gc_cipher_ctx *ctx = handle; @@ -317,16 +318,18 @@ MHD_gc_cipher_setkey (MHD_gc_cipher_handle handle, size_t keylen, const char *ke sprintf (&keyMaterial[2 * i], "%02x", key[i] & 0xFF); rc = MHD_rijndaelMakeKey (&ctx->aesEncKey, RIJNDAEL_DIR_ENCRYPT, - keylen * 8, keyMaterial); + keylen * 8, keyMaterial); if (rc < 0) return GC_INVALID_CIPHER; rc = MHD_rijndaelMakeKey (&ctx->aesDecKey, RIJNDAEL_DIR_DECRYPT, - keylen * 8, keyMaterial); + keylen * 8, keyMaterial); if (rc < 0) return GC_INVALID_CIPHER; - rc = MHD_MHD_rijndaelCipherInit (&ctx->aesContext, RIJNDAEL_MODE_ECB, NULL); + rc = + MHD_MHD_rijndaelCipherInit (&ctx->aesContext, RIJNDAEL_MODE_ECB, + NULL); if (rc < 0) return GC_INVALID_CIPHER; } @@ -341,7 +344,8 @@ MHD_gc_cipher_setkey (MHD_gc_cipher_handle handle, size_t keylen, const char *ke } Gc_rc -MHD_gc_cipher_setiv (MHD_gc_cipher_handle handle, size_t ivlen, const char *iv) +MHD_gc_cipher_setiv (MHD_gc_cipher_handle handle, size_t ivlen, + const char *iv) { _MHD_gc_cipher_ctx *ctx = handle; @@ -374,8 +378,9 @@ MHD_gc_cipher_setiv (MHD_gc_cipher_handle handle, size_t ivlen, const char *iv) for (i = 0; i < ivlen; i++) sprintf (&ivMaterial[2 * i], "%02x", iv[i] & 0xFF); - rc = MHD_MHD_rijndaelCipherInit (&ctx->aesContext, RIJNDAEL_MODE_CBC, - ivMaterial); + rc = + MHD_MHD_rijndaelCipherInit (&ctx->aesContext, RIJNDAEL_MODE_CBC, + ivMaterial); if (rc < 0) return GC_INVALID_CIPHER; } @@ -395,7 +400,8 @@ MHD_gc_cipher_setiv (MHD_gc_cipher_handle handle, size_t ivlen, const char *iv) } Gc_rc -MHD_gc_cipher_encrypt_inline (MHD_gc_cipher_handle handle, size_t len, char *data) +MHD_gc_cipher_encrypt_inline (MHD_gc_cipher_handle handle, size_t len, + char *data) { _MHD_gc_cipher_ctx *ctx = handle; @@ -450,7 +456,7 @@ MHD_gc_cipher_encrypt_inline (MHD_gc_cipher_handle handle, size_t len, char *dat int nblocks; nblocks = MHD_rijndaelBlockEncrypt (&ctx->aesContext, &ctx->aesEncKey, - data, 8 * len, data); + data, 8 * len, data); if (nblocks < 0) return GC_INVALID_CIPHER; } @@ -465,7 +471,8 @@ MHD_gc_cipher_encrypt_inline (MHD_gc_cipher_handle handle, size_t len, char *dat } Gc_rc -MHD_gc_cipher_decrypt_inline (MHD_gc_cipher_handle handle, size_t len, char *data) +MHD_gc_cipher_decrypt_inline (MHD_gc_cipher_handle handle, size_t len, + char *data) { _MHD_gc_cipher_ctx *ctx = handle; @@ -522,7 +529,7 @@ MHD_gc_cipher_decrypt_inline (MHD_gc_cipher_handle handle, size_t len, char *dat int nblocks; nblocks = MHD_rijndaelBlockDecrypt (&ctx->aesContext, &ctx->aesDecKey, - data, 8 * len, data); + data, 8 * len, data); if (nblocks < 0) return GC_INVALID_CIPHER; } @@ -565,7 +572,8 @@ typedef struct _MHD_gc_hash_ctx } _MHD_gc_hash_ctx; Gc_rc -MHD_gc_hash_open (Gc_hash hash, Gc_hash_mode mode, MHD_gc_hash_handle * outhandle) +MHD_gc_hash_open (Gc_hash hash, Gc_hash_mode mode, + MHD_gc_hash_handle * outhandle) { _MHD_gc_hash_ctx *ctx; Gc_rc rc = GC_OK; @@ -769,7 +777,7 @@ MHD_gc_sha1 (const void *in, size_t inlen, void *resbuf) #ifdef GNULIB_GC_HMAC_MD5 Gc_rc MHD_gc_MHD_hmac_md5 (const void *key, size_t keylen, - const void *in, size_t inlen, char *resbuf) + const void *in, size_t inlen, char *resbuf) { MHD_hmac_md5 (key, keylen, in, inlen, resbuf); return GC_OK; @@ -779,7 +787,8 @@ MHD_gc_MHD_hmac_md5 (const void *key, size_t keylen, #ifdef GNULIB_GC_HMAC_SHA1 Gc_rc MHD_gc_MHD_hmac_sha1 (const void *key, - size_t keylen, const void *in, size_t inlen, char *resbuf) + size_t keylen, const void *in, size_t inlen, + char *resbuf) { MHD_hmac_sha1 (key, keylen, in, inlen, resbuf); return GC_OK; diff --git a/src/daemon/https/lgl/gc-libgcrypt.c b/src/daemon/https/lgl/gc-libgcrypt.c @@ -90,9 +90,9 @@ MHD_gc_random (char *data, size_t datalen) void MHD_gc_set_allocators (MHD_gc_malloc_t func_malloc, - MHD_gc_malloc_t secure_malloc, - MHD_gc_secure_check_t secure_check, - MHD_gc_realloc_t func_realloc, MHD_gc_free_t func_free) + MHD_gc_malloc_t secure_malloc, + MHD_gc_secure_check_t secure_check, + MHD_gc_realloc_t func_realloc, MHD_gc_free_t func_free) { gcry_set_allocation_handler (func_malloc, secure_malloc, secure_check, func_realloc, func_free); @@ -102,7 +102,7 @@ MHD_gc_set_allocators (MHD_gc_malloc_t func_malloc, Gc_rc MHD_gc_cipher_open (Gc_cipher alg, - Gc_cipher_mode mode, MHD_gc_cipher_handle * outhandle) + Gc_cipher_mode mode, MHD_gc_cipher_handle * outhandle) { int gcryalg, gcrymode; gcry_error_t err; @@ -179,7 +179,8 @@ MHD_gc_cipher_open (Gc_cipher alg, } Gc_rc -MHD_gc_cipher_setkey (MHD_gc_cipher_handle handle, size_t keylen, const char *key) +MHD_gc_cipher_setkey (MHD_gc_cipher_handle handle, size_t keylen, + const char *key) { gcry_error_t err; @@ -191,7 +192,8 @@ MHD_gc_cipher_setkey (MHD_gc_cipher_handle handle, size_t keylen, const char *ke } Gc_rc -MHD_gc_cipher_setiv (MHD_gc_cipher_handle handle, size_t ivlen, const char *iv) +MHD_gc_cipher_setiv (MHD_gc_cipher_handle handle, size_t ivlen, + const char *iv) { gcry_error_t err; @@ -203,7 +205,8 @@ MHD_gc_cipher_setiv (MHD_gc_cipher_handle handle, size_t ivlen, const char *iv) } Gc_rc -MHD_gc_cipher_encrypt_inline (MHD_gc_cipher_handle handle, size_t len, char *data) +MHD_gc_cipher_encrypt_inline (MHD_gc_cipher_handle handle, size_t len, + char *data) { if (gcry_cipher_encrypt ((gcry_cipher_hd_t) handle, data, len, NULL, len) != 0) @@ -213,7 +216,8 @@ MHD_gc_cipher_encrypt_inline (MHD_gc_cipher_handle handle, size_t len, char *dat } Gc_rc -MHD_gc_cipher_decrypt_inline (MHD_gc_cipher_handle handle, size_t len, char *data) +MHD_gc_cipher_decrypt_inline (MHD_gc_cipher_handle handle, size_t len, + char *data) { if (gcry_cipher_decrypt ((gcry_cipher_hd_t) handle, data, len, NULL, len) != 0) @@ -240,7 +244,8 @@ typedef struct _MHD_gc_hash_ctx } _MHD_gc_hash_ctx; Gc_rc -MHD_gc_hash_open (Gc_hash hash, Gc_hash_mode mode, MHD_gc_hash_handle * outhandle) +MHD_gc_hash_open (Gc_hash hash, Gc_hash_mode mode, + MHD_gc_hash_handle * outhandle) { _MHD_gc_hash_ctx *ctx; int gcryalg = 0, gcrymode = 0; @@ -391,7 +396,8 @@ MHD_gc_hash_digest_length (Gc_hash hash) } void -MHD_gc_hash_MHD_hmac_setkey (MHD_gc_hash_handle handle, size_t len, const char *key) +MHD_gc_hash_MHD_hmac_setkey (MHD_gc_hash_handle handle, size_t len, + const char *key) { _MHD_gc_hash_ctx *ctx = handle; gcry_md_setkey (ctx->gch, key, len); @@ -411,7 +417,7 @@ MHD_gc_hash_read (MHD_gc_hash_handle handle) const char *digest; { gcry_md_final (ctx->gch); - digest = (const char*) gcry_md_read (ctx->gch, 0); + digest = (const char *) gcry_md_read (ctx->gch, 0); } return digest; @@ -547,7 +553,7 @@ MHD_gc_sha1 (const void *in, size_t inlen, void *resbuf) #ifdef GNULIB_GC_HMAC_MD5 Gc_rc MHD_gc_MHD_hmac_md5 (const void *key, size_t keylen, - const void *in, size_t inlen, char *resbuf) + const void *in, size_t inlen, char *resbuf) { size_t hlen = gcry_md_get_algo_dlen (GCRY_MD_MD5); gcry_md_hd_t mdh; @@ -587,7 +593,8 @@ MHD_gc_MHD_hmac_md5 (const void *key, size_t keylen, #ifdef GNULIB_GC_HMAC_SHA1 Gc_rc MHD_gc_MHD_hmac_sha1 (const void *key, - size_t keylen, const void *in, size_t inlen, char *resbuf) + size_t keylen, const void *in, size_t inlen, + char *resbuf) { size_t hlen = gcry_md_get_algo_dlen (GCRY_MD_SHA1); gcry_md_hd_t mdh; diff --git a/src/daemon/https/lgl/gc-pbkdf2-sha1.c b/src/daemon/https/lgl/gc-pbkdf2-sha1.c @@ -53,8 +53,8 @@ Gc_rc MHD_gc_pbkdf2_sha1 (const char *P, size_t Plen, - const char *S, size_t Slen, - unsigned int c, char *DK, size_t dkLen) + const char *S, size_t Slen, + unsigned int c, char *DK, size_t dkLen) { unsigned int hLen = 20; char U[20]; diff --git a/src/daemon/https/lgl/gc.h b/src/daemon/https/lgl/gc.h @@ -105,9 +105,10 @@ typedef int (*MHD_gc_secure_check_t) (const void *); typedef void *(*MHD_gc_realloc_t) (void *p, size_t n); typedef void (*MHD_gc_free_t) (void *); void MHD_gc_set_allocators (MHD_gc_malloc_t func_malloc, - MHD_gc_malloc_t secure_malloc, - MHD_gc_secure_check_t secure_check, - MHD_gc_realloc_t func_realloc, MHD_gc_free_t func_free); + MHD_gc_malloc_t secure_malloc, + MHD_gc_secure_check_t secure_check, + MHD_gc_realloc_t func_realloc, + MHD_gc_free_t func_free); /* Randomness. */ Gc_rc MHD_gc_nonce (char *data, size_t datalen); @@ -116,24 +117,29 @@ Gc_rc MHD_gc_random (char *data, size_t datalen); /* Ciphers. */ Gc_rc MHD_gc_cipher_open (Gc_cipher cipher, - Gc_cipher_mode mode, MHD_gc_cipher_handle * outhandle); -Gc_rc MHD_gc_cipher_setkey (MHD_gc_cipher_handle handle, - size_t keylen, const char *key); -Gc_rc MHD_gc_cipher_setiv (MHD_gc_cipher_handle handle, size_t ivlen, const char *iv); -Gc_rc MHD_gc_cipher_encrypt_inline (MHD_gc_cipher_handle handle, - size_t len, char *data); -Gc_rc MHD_gc_cipher_decrypt_inline (MHD_gc_cipher_handle handle, - size_t len, char *data); + Gc_cipher_mode mode, + MHD_gc_cipher_handle * outhandle); +Gc_rc MHD_gc_cipher_setkey (MHD_gc_cipher_handle handle, size_t keylen, + const char *key); +Gc_rc MHD_gc_cipher_setiv (MHD_gc_cipher_handle handle, size_t ivlen, + const char *iv); +Gc_rc MHD_gc_cipher_encrypt_inline (MHD_gc_cipher_handle handle, size_t len, + char *data); +Gc_rc MHD_gc_cipher_decrypt_inline (MHD_gc_cipher_handle handle, size_t len, + char *data); Gc_rc MHD_gc_cipher_close (MHD_gc_cipher_handle handle); /* Hashes. */ Gc_rc MHD_gc_hash_open (Gc_hash hash, - Gc_hash_mode mode, MHD_gc_hash_handle * outhandle); -Gc_rc MHD_gc_hash_clone (MHD_gc_hash_handle handle, MHD_gc_hash_handle * outhandle); + Gc_hash_mode mode, MHD_gc_hash_handle * outhandle); +Gc_rc MHD_gc_hash_clone (MHD_gc_hash_handle handle, + MHD_gc_hash_handle * outhandle); size_t MHD_gc_hash_digest_length (Gc_hash hash); -void MHD_gc_hash_MHD_hmac_setkey (MHD_gc_hash_handle handle, size_t len, const char *key); -void MHD_gc_hash_write (MHD_gc_hash_handle handle, size_t len, const char *data); +void MHD_gc_hash_MHD_hmac_setkey (MHD_gc_hash_handle handle, size_t len, + const char *key); +void MHD_gc_hash_write (MHD_gc_hash_handle handle, size_t len, + const char *data); const char *MHD_gc_hash_read (MHD_gc_hash_handle handle); void MHD_gc_hash_close (MHD_gc_hash_handle handle); @@ -143,7 +149,8 @@ void MHD_gc_hash_close (MHD_gc_hash_handle handle); GC_<HASH>_DIGEST_SIZE. For example, for GC_MD5 the output buffer must be 16 bytes. The return value is 0 (GC_OK) on success, or another Gc_rc error code. */ -Gc_rc MHD_gc_hash_buffer (Gc_hash hash, const void *in, size_t inlen, char *out); +Gc_rc MHD_gc_hash_buffer (Gc_hash hash, const void *in, size_t inlen, + char *out); /* One-call interface. */ Gc_rc MHD_gc_md2 (const void *in, size_t inlen, void *resbuf); @@ -151,10 +158,10 @@ Gc_rc MHD_gc_md4 (const void *in, size_t inlen, void *resbuf); Gc_rc MHD_gc_md5 (const void *in, size_t inlen, void *resbuf); Gc_rc MHD_gc_sha1 (const void *in, size_t inlen, void *resbuf); Gc_rc MHD_gc_MHD_hmac_md5 (const void *key, - size_t keylen, const void *in, size_t inlen, char *resbuf); -Gc_rc MHD_gc_MHD_hmac_sha1 (const void *key, - size_t keylen, - const void *in, size_t inlen, char *resbuf); + size_t keylen, const void *in, size_t inlen, + char *resbuf); +Gc_rc MHD_gc_MHD_hmac_sha1 (const void *key, size_t keylen, const void *in, + size_t inlen, char *resbuf); /* Derive cryptographic keys from a password P of length PLEN, with salt S of length SLEN, placing the result in pre-allocated buffer @@ -164,9 +171,10 @@ Gc_rc MHD_gc_MHD_hmac_sha1 (const void *key, exactly dkLen bytes long. GC_OK is returned on success, otherwise an Gc_rc error code is returned. */ Gc_rc MHD_gc_pbkdf2_sha1 (const char *P, - size_t Plen, - const char *S, - size_t Slen, unsigned int c, char *DK, size_t dkLen); + size_t Plen, + const char *S, + size_t Slen, unsigned int c, char *DK, + size_t dkLen); /* TODO: diff --git a/src/daemon/https/lgl/hmac-md5.c b/src/daemon/https/lgl/hmac-md5.c @@ -31,7 +31,7 @@ int MHD_hmac_md5 (const void *key, size_t keylen, - const void *in, size_t inlen, void *resbuf) + const void *in, size_t inlen, void *resbuf) { struct MHD_md5_ctx inner; struct MHD_md5_ctx outer; diff --git a/src/daemon/https/lgl/hmac-sha1.c b/src/daemon/https/lgl/hmac-sha1.c @@ -31,7 +31,7 @@ int MHD_hmac_sha1 (const void *key, size_t keylen, - const void *in, size_t inlen, void *resbuf) + const void *in, size_t inlen, void *resbuf) { struct MHD_sha1_ctx inner; struct MHD_sha1_ctx outer; diff --git a/src/daemon/https/lgl/hmac.h b/src/daemon/https/lgl/hmac.h @@ -28,7 +28,7 @@ RESBUF buffer. Return 0 on success. */ int MHD_hmac_md5 (const void *key, size_t keylen, - const void *buffer, size_t buflen, void *resbuf); + const void *buffer, size_t buflen, void *resbuf); /* Compute Hashed Message Authentication Code with SHA-1, over BUFFER data of BUFLEN bytes using the KEY of KEYLEN bytes, writing the @@ -36,6 +36,6 @@ MHD_hmac_md5 (const void *key, size_t keylen, success. */ int MHD_hmac_sha1 (const void *key, size_t keylen, - const void *in, size_t inlen, void *resbuf); + const void *in, size_t inlen, void *resbuf); #endif /* HMAC_H */ diff --git a/src/daemon/https/lgl/md5.c b/src/daemon/https/lgl/md5.c @@ -212,7 +212,8 @@ MHD_md5_buffer (const char *buffer, size_t len, void *resblock) void -MHD_md5_process_bytes (const void *buffer, size_t len, struct MHD_md5_ctx *ctx) +MHD_md5_process_bytes (const void *buffer, size_t len, + struct MHD_md5_ctx *ctx) { /* When we already have some bits in our internal buffer concatenate both inputs first. */ @@ -292,7 +293,8 @@ MHD_md5_process_bytes (const void *buffer, size_t len, struct MHD_md5_ctx *ctx) It is assumed that LEN % 64 == 0. */ void -MHD_md5_process_block (const void *buffer, size_t len, struct MHD_md5_ctx *ctx) +MHD_md5_process_block (const void *buffer, size_t len, + struct MHD_md5_ctx *ctx) { uint32_t correct_words[16]; const uint32_t *words = buffer; diff --git a/src/daemon/https/lgl/md5.h b/src/daemon/https/lgl/md5.h @@ -83,14 +83,14 @@ __MHD_md5_init_ctx (struct MHD_md5_ctx *ctx) starting at BUFFER. It is necessary that LEN is a multiple of 64!!! */ extern void __MHD_md5_process_block (const void *buffer, size_t len, - struct MHD_md5_ctx *ctx) __THROW; + struct MHD_md5_ctx *ctx) __THROW; /* Starting with the result of former calls of this function (or the initialization function update the context for the next LEN bytes starting at BUFFER. It is NOT required that LEN is a multiple of 64. */ extern void __MHD_md5_process_bytes (const void *buffer, size_t len, - struct MHD_md5_ctx *ctx) __THROW; + struct MHD_md5_ctx *ctx) __THROW; /* Process the remaining bytes in the buffer and put result from CTX in first 16 bytes following RESBUF. The result is always in little @@ -100,7 +100,7 @@ __MHD_md5_init_ctx (struct MHD_md5_ctx *ctx) IMPORTANT: On some systems, RESBUF must be aligned to a 32-bit boundary. */ extern void *__MHD_md5_finish_ctx (struct MHD_md5_ctx *ctx, - void *resbuf) __THROW; + void *resbuf) __THROW; /* Put result from CTX in first 16 bytes following RESBUF. The result is @@ -110,7 +110,7 @@ __MHD_md5_init_ctx (struct MHD_md5_ctx *ctx) IMPORTANT: On some systems, RESBUF must be aligned to a 32-bit boundary. */ extern void *__MHD_md5_read_ctx (const struct MHD_md5_ctx *ctx, - void *resbuf) __THROW; + void *resbuf) __THROW; /* Compute MD5 message digest for bytes read from STREAM. The @@ -123,6 +123,6 @@ __MHD_md5_init_ctx (struct MHD_md5_ctx *ctx) output yields to the wanted ASCII representation of the message digest. */ extern void *__MHD_md5_buffer (const char *buffer, size_t len, - void *resblock) __THROW; + void *resblock) __THROW; #endif /* md5.h */ diff --git a/src/daemon/https/lgl/rijndael-alg-fst.c b/src/daemon/https/lgl/rijndael-alg-fst.c @@ -763,7 +763,7 @@ static const uint32_t rcon[] = { */ int MHD_rijndaelKeySetupEnc (uint32_t rk[ /*4*(Nr + 1) */ ], - const char cipherKey[], size_t keyBits) + const char cipherKey[], size_t keyBits) { size_t i = 0; uint32_t temp; @@ -858,7 +858,7 @@ MHD_rijndaelKeySetupEnc (uint32_t rk[ /*4*(Nr + 1) */ ], */ int MHD_rijndaelKeySetupDec (uint32_t rk[ /*4*(Nr + 1) */ ], - const char cipherKey[], size_t keyBits) + const char cipherKey[], size_t keyBits) { size_t Nr, i, j; uint32_t temp; @@ -912,7 +912,7 @@ MHD_rijndaelKeySetupDec (uint32_t rk[ /*4*(Nr + 1) */ ], void MHD_rijndaelEncrypt (const uint32_t rk[ /*4*(Nr + 1) */ ], size_t Nr, - const char pt[16], char ct[16]) + const char pt[16], char ct[16]) { uint32_t s0, s1, s2, s3, t0, t1, t2, t3; size_t r; @@ -1003,7 +1003,7 @@ MHD_rijndaelEncrypt (const uint32_t rk[ /*4*(Nr + 1) */ ], size_t Nr, void MHD_rijndaelDecrypt (const uint32_t rk[ /*4*(Nr + 1) */ ], size_t Nr, - const char ct[16], char pt[16]) + const char ct[16], char pt[16]) { uint32_t s0, s1, s2, s3, t0, t1, t2, t3; size_t r; diff --git a/src/daemon/https/lgl/rijndael-alg-fst.h b/src/daemon/https/lgl/rijndael-alg-fst.h @@ -56,12 +56,12 @@ #define RIJNDAEL_MAXNR 14 int MHD_rijndaelKeySetupEnc (uint32_t rk[ /*4*(Nr + 1) */ ], - const char cipherKey[], size_t keyBits); + const char cipherKey[], size_t keyBits); int MHD_rijndaelKeySetupDec (uint32_t rk[ /*4*(Nr + 1) */ ], - const char cipherKey[], size_t keyBits); + const char cipherKey[], size_t keyBits); void MHD_rijndaelEncrypt (const uint32_t rk[ /*4*(Nr + 1) */ ], size_t Nr, - const char pt[16], char ct[16]); + const char pt[16], char ct[16]); void MHD_rijndaelDecrypt (const uint32_t rk[ /*4*(Nr + 1) */ ], size_t Nr, - const char ct[16], char pt[16]); + const char ct[16], char pt[16]); #endif /* __RIJNDAEL_ALG_FST_H */ diff --git a/src/daemon/https/lgl/rijndael-api-fst.c b/src/daemon/https/lgl/rijndael-api-fst.c @@ -73,7 +73,7 @@ rijndael_rc MHD_rijndaelMakeKey (rijndaelKeyInstance * key, rijndael_direction direction, - size_t keyLen, const char *keyMaterial) + size_t keyLen, const char *keyMaterial) { size_t i; char *keyMat; @@ -149,8 +149,8 @@ MHD_rijndaelMakeKey (rijndaelKeyInstance * key, rijndael_direction direction, } rijndael_rc -MHD_MHD_rijndaelCipherInit (rijndaelCipherInstance * cipher, rijndael_mode mode, - const char *IV) +MHD_MHD_rijndaelCipherInit (rijndaelCipherInstance * cipher, + rijndael_mode mode, const char *IV) { if ((mode == RIJNDAEL_MODE_ECB) || (mode == RIJNDAEL_MODE_CBC) || (mode == RIJNDAEL_MODE_CFB1)) @@ -200,8 +200,8 @@ MHD_MHD_rijndaelCipherInit (rijndaelCipherInstance * cipher, rijndael_mode mode, int MHD_rijndaelBlockEncrypt (rijndaelCipherInstance * cipher, - const rijndaelKeyInstance * key, - const char *input, size_t inputLen, char *outBuffer) + const rijndaelKeyInstance * key, + const char *input, size_t inputLen, char *outBuffer) { size_t i, k, t, numBlocks; char block[16], *iv; @@ -277,8 +277,9 @@ MHD_rijndaelBlockEncrypt (rijndaelCipherInstance * cipher, int MHD_rijndaelPadEncrypt (rijndaelCipherInstance * cipher, - const rijndaelKeyInstance * key, - const char *input, size_t inputOctets, char *outBuffer) + const rijndaelKeyInstance * key, + const char *input, size_t inputOctets, + char *outBuffer) { size_t i, numBlocks, padLen; char block[16], *iv; @@ -350,8 +351,8 @@ MHD_rijndaelPadEncrypt (rijndaelCipherInstance * cipher, int MHD_rijndaelBlockDecrypt (rijndaelCipherInstance * cipher, - const rijndaelKeyInstance * key, - const char *input, size_t inputLen, char *outBuffer) + const rijndaelKeyInstance * key, + const char *input, size_t inputLen, char *outBuffer) { size_t i, k, t, numBlocks; char block[16], *iv; @@ -426,8 +427,9 @@ MHD_rijndaelBlockDecrypt (rijndaelCipherInstance * cipher, int MHD_rijndaelPadDecrypt (rijndaelCipherInstance * cipher, - const rijndaelKeyInstance * key, - const char *input, size_t inputOctets, char *outBuffer) + const rijndaelKeyInstance * key, + const char *input, size_t inputOctets, + char *outBuffer) { size_t i, numBlocks, padLen; char block[16]; diff --git a/src/daemon/https/lgl/rijndael-api-fst.h b/src/daemon/https/lgl/rijndael-api-fst.h @@ -138,7 +138,7 @@ typedef struct 128, 192 or 256. Returns 0 on success, or an error code. */ extern rijndael_rc MHD_rijndaelMakeKey (rijndaelKeyInstance * key, rijndael_direction direction, - size_t keyLen, const char *keyMaterial); + size_t keyLen, const char *keyMaterial); /* Initialize cipher state CIPHER for encryption MODE (e.g., RIJNDAEL_MODE_CBC) with initialization vector IV, a hex string of @@ -146,7 +146,7 @@ MHD_rijndaelMakeKey (rijndaelKeyInstance * key, rijndael_direction direction, not need an IV (i.e., RIJNDAEL_MODE_ECB). */ extern rijndael_rc MHD_MHD_rijndaelCipherInit (rijndaelCipherInstance * cipher, - rijndael_mode mode, const char *IV); + rijndael_mode mode, const char *IV); /* Encrypt data in INPUT, of INPUTLEN/8 bytes length, placing the output in the pre-allocated OUTBUFFER which must hold at least @@ -157,8 +157,9 @@ MHD_MHD_rijndaelCipherInit (rijndaelCipherInstance * cipher, negative rijndael_rc error code. */ extern int MHD_rijndaelBlockEncrypt (rijndaelCipherInstance * cipher, - const rijndaelKeyInstance * key, - const char *input, size_t inputLen, char *outBuffer); + const rijndaelKeyInstance * key, + const char *input, size_t inputLen, + char *outBuffer); /* Encrypt data in INPUT, of INPUTOCTETS bytes length, placing the output in the pre-allocated OUTBUFFER which must hold at least @@ -171,8 +172,9 @@ MHD_rijndaelBlockEncrypt (rijndaelCipherInstance * cipher, negative rijndael_rc error code. */ extern int MHD_rijndaelPadEncrypt (rijndaelCipherInstance * cipher, - const rijndaelKeyInstance * key, - const char *input, size_t inputOctets, char *outBuffer); + const rijndaelKeyInstance * key, + const char *input, size_t inputOctets, + char *outBuffer); /* Decrypt data in INPUT, of INPUTLEN/8 bytes length, placing the output in the pre-allocated OUTBUFFER which must hold at least @@ -183,8 +185,9 @@ MHD_rijndaelPadEncrypt (rijndaelCipherInstance * cipher, negative rijndael_rc error code. */ extern int MHD_rijndaelBlockDecrypt (rijndaelCipherInstance * cipher, - const rijndaelKeyInstance * key, - const char *input, size_t inputLen, char *outBuffer); + const rijndaelKeyInstance * key, + const char *input, size_t inputLen, + char *outBuffer); /* Decrypt data in INPUT, of INPUTOCTETS bytes length, placing the output in the pre-allocated OUTBUFFER which must hold at least @@ -197,7 +200,8 @@ MHD_rijndaelBlockDecrypt (rijndaelCipherInstance * cipher, negative rijndael_rc error code. */ extern int MHD_rijndaelPadDecrypt (rijndaelCipherInstance * cipher, - const rijndaelKeyInstance * key, - const char *input, size_t inputOctets, char *outBuffer); + const rijndaelKeyInstance * key, + const char *input, size_t inputOctets, + char *outBuffer); #endif /* __RIJNDAEL_API_FST_H */ diff --git a/src/daemon/https/lgl/sha1.c b/src/daemon/https/lgl/sha1.c @@ -199,7 +199,8 @@ MHD_sha1_buffer (const char *buffer, size_t len, void *resblock) } void -MHD_sha1_process_bytes (const void *buffer, size_t len, struct MHD_sha1_ctx *ctx) +MHD_sha1_process_bytes (const void *buffer, size_t len, + struct MHD_sha1_ctx *ctx) { /* When we already have some bits in our internal buffer concatenate both inputs first. */ @@ -235,7 +236,8 @@ MHD_sha1_process_bytes (const void *buffer, size_t len, struct MHD_sha1_ctx *ctx if (UNALIGNED_P (buffer)) while (len > 64) { - MHD_sha1_process_block (memcpy (ctx->buffer, buffer, 64), 64, ctx); + MHD_sha1_process_block (memcpy (ctx->buffer, buffer, 64), 64, + ctx); buffer = (const char *) buffer + 64; len -= 64; } @@ -284,7 +286,8 @@ MHD_sha1_process_bytes (const void *buffer, size_t len, struct MHD_sha1_ctx *ctx Most of this code comes from GnuPG's cipher/sha1.c. */ void -MHD_sha1_process_block (const void *buffer, size_t len, struct MHD_sha1_ctx *ctx) +MHD_sha1_process_block (const void *buffer, size_t len, + struct MHD_sha1_ctx *ctx) { const uint32_t *words = buffer; size_t nwords = len / sizeof (uint32_t); diff --git a/src/daemon/https/lgl/sha1.h b/src/daemon/https/lgl/sha1.h @@ -45,14 +45,14 @@ extern void MHD_sha1_init_ctx (struct MHD_sha1_ctx *ctx); starting at BUFFER. It is necessary that LEN is a multiple of 64!!! */ extern void MHD_sha1_process_block (const void *buffer, size_t len, - struct MHD_sha1_ctx *ctx); + struct MHD_sha1_ctx *ctx); /* Starting with the result of former calls of this function (or the initialization function update the context for the next LEN bytes starting at BUFFER. It is NOT required that LEN is a multiple of 64. */ extern void MHD_sha1_process_bytes (const void *buffer, size_t len, - struct MHD_sha1_ctx *ctx); + struct MHD_sha1_ctx *ctx); /* Process the remaining bytes in the buffer and put result from CTX in first 20 bytes following RESBUF. The result is always in little diff --git a/src/daemon/https/minitasn1/coding.c b/src/daemon/https/minitasn1/coding.c @@ -47,15 +47,16 @@ /******************************************************/ static void MHD__asn1_error_description_value_not_found (node_asn * node, - char *ErrorDescription) + char *ErrorDescription) { if (ErrorDescription == NULL) return; Estrcpy (ErrorDescription, ":: value of element '"); - MHD__asn1_hierarchical_name (node, ErrorDescription + strlen (ErrorDescription), - MAX_ERROR_DESCRIPTION_SIZE - 40); + MHD__asn1_hierarchical_name (node, + ErrorDescription + strlen (ErrorDescription), + MAX_ERROR_DESCRIPTION_SIZE - 40); Estrcat (ErrorDescription, "' not found"); } @@ -115,7 +116,7 @@ MHD__asn1_length_der (unsigned long int len, unsigned char *ans, int *ans_len) /******************************************************/ static void MHD__asn1_tag_der (unsigned char class, unsigned int tag_value, - unsigned char *ans, int *ans_len) + unsigned char *ans, int *ans_len) { int k; unsigned char temp[SIZEOF_UNSIGNED_INT]; @@ -154,7 +155,7 @@ MHD__asn1_tag_der (unsigned char class, unsigned int tag_value, **/ void MHD__asn1_octet_der (const unsigned char *str, int str_len, - unsigned char *der, int *der_len) + unsigned char *der, int *der_len) { int len_len; @@ -187,11 +188,12 @@ MHD__asn1_time_der (unsigned char *str, unsigned char *der, int *der_len) max_len = *der_len; - MHD__asn1_length_der (strlen ((const char*) str), (max_len > 0) ? der : NULL, &len_len); + MHD__asn1_length_der (strlen ((const char *) str), + (max_len > 0) ? der : NULL, &len_len); - if ((len_len + (int) strlen ((const char*) str)) <= max_len) - memcpy (der + len_len, str, strlen ((const char*) str)); - *der_len = len_len + strlen ((const char*) str); + if ((len_len + (int) strlen ((const char *) str)) <= max_len) + memcpy (der + len_len, str, strlen ((const char *) str)); + *der_len = len_len + strlen ((const char *) str); if ((*der_len) > max_len) return ASN1_MEM_ERROR; @@ -223,11 +225,11 @@ MHD__asn1_objectid_der (unsigned char *str, unsigned char *der, int *der_len) max_len = *der_len; - temp = (char *) MHD__asn1_alloca (strlen ((const char*)str) + 2); + temp = (char *) MHD__asn1_alloca (strlen ((const char *) str) + 2); if (temp == NULL) return ASN1_MEM_ALLOC_ERROR; - strcpy (temp, (const char*) str); + strcpy (temp, (const char *) str); strcat (temp, "."); counter = 0; @@ -284,7 +286,8 @@ MHD__asn1_objectid_der (unsigned char *str, unsigned char *der, int *der_len) } -const char MHD_bit_mask[] = { 0xFF, 0xFE, 0xFC, 0xF8, 0xF0, 0xE0, 0xC0, 0x80 }; +const char MHD_bit_mask[] = + { 0xFF, 0xFE, 0xFC, 0xF8, 0xF0, 0xE0, 0xC0, 0x80 }; /** * MHD__asn1_bit_der: @@ -299,7 +302,7 @@ const char MHD_bit_mask[] = { 0xFF, 0xFE, 0xFC, 0xF8, 0xF0, 0xE0, 0xC0, 0x80 }; **/ void MHD__asn1_bit_der (const unsigned char *str, int bit_len, - unsigned char *der, int *der_len) + unsigned char *der, int *der_len) { int len_len, len_byte, len_pad; @@ -335,7 +338,7 @@ MHD__asn1_bit_der (const unsigned char *str, int bit_len, /******************************************************/ static MHD__asn1_retCode MHD__asn1_complete_explicit_tag (node_asn * node, unsigned char *der, - int *counter, int *max_len) + int *counter, int *max_len) { node_asn *p; int is_tag_implicit, len2, len3; @@ -408,7 +411,7 @@ MHD__asn1_complete_explicit_tag (node_asn * node, unsigned char *der, /******************************************************/ static MHD__asn1_retCode MHD__asn1_insert_tag_der (node_asn * node, unsigned char *der, int *counter, - int *max_len) + int *max_len) { node_asn *p; int tag_len, is_tag_implicit; @@ -438,21 +441,20 @@ MHD__asn1_insert_tag_der (node_asn * node, unsigned char *der, int *counter, { if (is_tag_implicit) MHD__asn1_tag_der (class_implicit, tag_implicit, - (unsigned char*) tag_der, - &tag_len); + (unsigned char *) tag_der, &tag_len); else MHD__asn1_tag_der (class | ASN1_CLASS_STRUCTURED, - strtoul ( (const char*) p->value, NULL, 10), - (unsigned char*) tag_der, - &tag_len); + strtoul ((const char *) p->value, NULL, + 10), + (unsigned char *) tag_der, &tag_len); *max_len -= tag_len; if (*max_len >= 0) memcpy (der + *counter, tag_der, tag_len); *counter += tag_len; - MHD__asn1_ltostr (*counter, (char*) temp); - MHD__asn1_set_name (p, (const char*) temp); + MHD__asn1_ltostr (*counter, (char *) temp); + MHD__asn1_set_name (p, (const char *) temp); is_tag_implicit = 0; } @@ -466,7 +468,8 @@ MHD__asn1_insert_tag_der (node_asn * node, unsigned char *der, int *counter, (type_field (node->type) == TYPE_SET_OF)) class |= ASN1_CLASS_STRUCTURED; class_implicit = class; - tag_implicit = strtoul ( (const char*) p->value, NULL, 10); + tag_implicit = + strtoul ((const char *) p->value, NULL, 10); is_tag_implicit = 1; } } @@ -477,63 +480,66 @@ MHD__asn1_insert_tag_der (node_asn * node, unsigned char *der, int *counter, if (is_tag_implicit) { - MHD__asn1_tag_der (class_implicit, tag_implicit, (unsigned char*) tag_der, &tag_len); + MHD__asn1_tag_der (class_implicit, tag_implicit, + (unsigned char *) tag_der, &tag_len); } else { switch (type_field (node->type)) { case TYPE_NULL: - MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_NULL, (unsigned char*) tag_der, - &tag_len); + MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_NULL, + (unsigned char *) tag_der, &tag_len); break; case TYPE_BOOLEAN: - MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_BOOLEAN, (unsigned char*) tag_der, - &tag_len); + MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_BOOLEAN, + (unsigned char *) tag_der, &tag_len); break; case TYPE_INTEGER: - MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_INTEGER, (unsigned char*) tag_der, - &tag_len); + MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_INTEGER, + (unsigned char *) tag_der, &tag_len); break; case TYPE_ENUMERATED: - MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_ENUMERATED, (unsigned char*) tag_der, - &tag_len); + MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_ENUMERATED, + (unsigned char *) tag_der, &tag_len); break; case TYPE_OBJECT_ID: - MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_OBJECT_ID, (unsigned char*) tag_der, - &tag_len); + MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_OBJECT_ID, + (unsigned char *) tag_der, &tag_len); break; case TYPE_TIME: if (node->type & CONST_UTC) { - MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_UTCTime, (unsigned char*) tag_der, - &tag_len); + MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_UTCTime, + (unsigned char *) tag_der, &tag_len); } else MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_GENERALIZEDTime, - (unsigned char*) tag_der, &tag_len); + (unsigned char *) tag_der, &tag_len); break; case TYPE_OCTET_STRING: - MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_OCTET_STRING, (unsigned char*) tag_der, - &tag_len); + MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_OCTET_STRING, + (unsigned char *) tag_der, &tag_len); break; case TYPE_GENERALSTRING: MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_GENERALSTRING, - (unsigned char*) tag_der, &tag_len); + (unsigned char *) tag_der, &tag_len); break; case TYPE_BIT_STRING: - MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_BIT_STRING, (unsigned char*) tag_der, - &tag_len); + MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL, ASN1_TAG_BIT_STRING, + (unsigned char *) tag_der, &tag_len); break; case TYPE_SEQUENCE: case TYPE_SEQUENCE_OF: MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL | ASN1_CLASS_STRUCTURED, - ASN1_TAG_SEQUENCE, (unsigned char*) tag_der, &tag_len); + ASN1_TAG_SEQUENCE, (unsigned char *) tag_der, + &tag_len); break; case TYPE_SET: case TYPE_SET_OF: MHD__asn1_tag_der (ASN1_CLASS_UNIVERSAL | ASN1_CLASS_STRUCTURED, - ASN1_TAG_SET, (unsigned char*) tag_der, &tag_len); + ASN1_TAG_SET, (unsigned char *) tag_der, + &tag_len); break; case TYPE_TAG: tag_len = 0; @@ -591,11 +597,11 @@ MHD__asn1_ordering_set (unsigned char *der, int der_len, node_asn * node) return; p = node->down; - while ( (p != NULL) && - ((type_field (p->type) == TYPE_TAG) - || (type_field (p->type) == TYPE_SIZE)) ) + while ((p != NULL) && + ((type_field (p->type) == TYPE_TAG) + || (type_field (p->type) == TYPE_SIZE))) p = p->right; - + if ((p == NULL) || (p->right == NULL)) return; @@ -623,7 +629,8 @@ MHD__asn1_ordering_set (unsigned char *der, int der_len, node_asn * node) counter += len2; /* extraction and length */ - len2 = MHD__asn1_get_length_der (der + counter, der_len - counter, &len); + len2 = + MHD__asn1_get_length_der (der + counter, der_len - counter, &len); if (len2 < 0) return; counter += len + len2; @@ -643,7 +650,8 @@ MHD__asn1_ordering_set (unsigned char *der, int der_len, node_asn * node) if (p_vet->value > p2_vet->value) { /* change position */ - temp = (unsigned char *) MHD__asn1_alloca (p_vet->end - counter); + temp = + (unsigned char *) MHD__asn1_alloca (p_vet->end - counter); if (temp == NULL) return; @@ -738,7 +746,8 @@ MHD__asn1_ordering_set_of (unsigned char *der, int der_len, node_asn * node) return; counter += len; - len2 = MHD__asn1_get_length_der (der + counter, der_len - counter, &len); + len2 = + MHD__asn1_get_length_der (der + counter, der_len - counter, &len); if (len2 < 0) return; counter += len + len2; @@ -781,7 +790,8 @@ MHD__asn1_ordering_set_of (unsigned char *der, int der_len, node_asn * node) if (change == 1) { /* change position */ - temp = (unsigned char *) MHD__asn1_alloca (p_vet->end - counter); + temp = + (unsigned char *) MHD__asn1_alloca (p_vet->end - counter); if (temp == NULL) return; @@ -837,8 +847,8 @@ MHD__asn1_ordering_set_of (unsigned char *der, int der_len, node_asn * node) * **/ MHD__asn1_retCode -MHD__asn1_der_coding (ASN1_TYPE element, const char *name, void *ider, int *len, - char *ErrorDescription) +MHD__asn1_der_coding (ASN1_TYPE element, const char *name, void *ider, + int *len, char *ErrorDescription) { node_asn *node, *p, *p2; char temp[SIZEOF_UNSIGNED_LONG_INT * 3 + 1]; @@ -894,7 +904,7 @@ MHD__asn1_der_coding (ASN1_TYPE element, const char *name, void *ider, int *len, if (p->value == NULL) { MHD__asn1_error_description_value_not_found (p, - ErrorDescription); + ErrorDescription); err = ASN1_VALUE_NOT_FOUND; goto error; } @@ -924,7 +934,7 @@ MHD__asn1_der_coding (ASN1_TYPE element, const char *name, void *ider, int *len, if (p->value == NULL) { MHD__asn1_error_description_value_not_found (p, - ErrorDescription); + ErrorDescription); err = ASN1_VALUE_NOT_FOUND; goto error; } @@ -952,7 +962,7 @@ MHD__asn1_der_coding (ASN1_TYPE element, const char *name, void *ider, int *len, if (p->value == NULL) { MHD__asn1_error_description_value_not_found (p, - ErrorDescription); + ErrorDescription); err = ASN1_VALUE_NOT_FOUND; goto error; } @@ -969,7 +979,8 @@ MHD__asn1_der_coding (ASN1_TYPE element, const char *name, void *ider, int *len, case TYPE_TIME: if (p->value == NULL) { - MHD__asn1_error_description_value_not_found (p, ErrorDescription); + MHD__asn1_error_description_value_not_found (p, + ErrorDescription); err = ASN1_VALUE_NOT_FOUND; goto error; } @@ -985,7 +996,8 @@ MHD__asn1_der_coding (ASN1_TYPE element, const char *name, void *ider, int *len, case TYPE_OCTET_STRING: if (p->value == NULL) { - MHD__asn1_error_description_value_not_found (p, ErrorDescription); + MHD__asn1_error_description_value_not_found (p, + ErrorDescription); err = ASN1_VALUE_NOT_FOUND; goto error; } @@ -1004,7 +1016,8 @@ MHD__asn1_der_coding (ASN1_TYPE element, const char *name, void *ider, int *len, case TYPE_GENERALSTRING: if (p->value == NULL) { - MHD__asn1_error_description_value_not_found (p, ErrorDescription); + MHD__asn1_error_description_value_not_found (p, + ErrorDescription); err = ASN1_VALUE_NOT_FOUND; goto error; } @@ -1023,7 +1036,8 @@ MHD__asn1_der_coding (ASN1_TYPE element, const char *name, void *ider, int *len, case TYPE_BIT_STRING: if (p->value == NULL) { - MHD__asn1_error_description_value_not_found (p, ErrorDescription); + MHD__asn1_error_description_value_not_found (p, + ErrorDescription); err = ASN1_VALUE_NOT_FOUND; goto error; } @@ -1069,11 +1083,12 @@ MHD__asn1_der_coding (ASN1_TYPE element, const char *name, void *ider, int *len, } else { /* move==UP */ - len2 = strtol ( (const char*) p->value, NULL, 10); + len2 = strtol ((const char *) p->value, NULL, 10); MHD__asn1_set_value (p, NULL, 0); if ((type_field (p->type) == TYPE_SET) && (max_len >= 0)) MHD__asn1_ordering_set (der + len2, max_len - len2, p); - MHD__asn1_length_der (counter - len2, (unsigned char*) temp, &len3); + MHD__asn1_length_der (counter - len2, (unsigned char *) temp, + &len3); max_len -= len3; if (max_len >= 0) { @@ -1109,14 +1124,15 @@ MHD__asn1_der_coding (ASN1_TYPE element, const char *name, void *ider, int *len, } if (move == UP) { - len2 = strtol ( (const char*) p->value, NULL, 10); + len2 = strtol ((const char *) p->value, NULL, 10); MHD__asn1_set_value (p, NULL, 0); if ((type_field (p->type) == TYPE_SET_OF) && (max_len - len2 > 0)) { MHD__asn1_ordering_set_of (der + len2, max_len - len2, p); } - MHD__asn1_length_der (counter - len2, (unsigned char*) temp, &len3); + MHD__asn1_length_der (counter - len2, (unsigned char *) temp, + &len3); max_len -= len3; if (max_len >= 0) { @@ -1130,7 +1146,8 @@ MHD__asn1_der_coding (ASN1_TYPE element, const char *name, void *ider, int *len, case TYPE_ANY: if (p->value == NULL) { - MHD__asn1_error_description_value_not_found (p, ErrorDescription); + MHD__asn1_error_description_value_not_found (p, + ErrorDescription); err = ASN1_VALUE_NOT_FOUND; goto error; } diff --git a/src/daemon/https/minitasn1/decoding.c b/src/daemon/https/minitasn1/decoding.c @@ -35,12 +35,14 @@ static void -MHD__asn1_error_description_tag_error (node_asn * node, char *ErrorDescription) +MHD__asn1_error_description_tag_error (node_asn * node, + char *ErrorDescription) { Estrcpy (ErrorDescription, ":: tag error near element '"); - MHD__asn1_hierarchical_name (node, ErrorDescription + strlen (ErrorDescription), - MAX_ERROR_DESCRIPTION_SIZE - 40); + MHD__asn1_hierarchical_name (node, + ErrorDescription + strlen (ErrorDescription), + MAX_ERROR_DESCRIPTION_SIZE - 40); Estrcat (ErrorDescription, "'"); } @@ -117,7 +119,7 @@ MHD__asn1_get_length_der (const unsigned char *der, int der_len, int *len) **/ int MHD__asn1_get_tag_der (const unsigned char *der, int der_len, - unsigned char *cls, int *len, unsigned long *tag) + unsigned char *cls, int *len, unsigned long *tag) { int punt, ris; @@ -178,8 +180,8 @@ MHD__asn1_get_tag_der (const unsigned char *der, int der_len, **/ int MHD__asn1_get_octet_der (const unsigned char *der, int der_len, - int *ret_len, unsigned char *str, int str_size, - int *str_len) + int *ret_len, unsigned char *str, int str_size, + int *str_len) { int len_len; @@ -209,7 +211,7 @@ MHD__asn1_get_octet_der (const unsigned char *der, int der_len, */ static int MHD__asn1_get_time_der (const unsigned char *der, int der_len, int *ret_len, - char *str, int str_size) + char *str, int str_size) { int len_len, str_len; @@ -228,8 +230,8 @@ MHD__asn1_get_time_der (const unsigned char *der, int der_len, int *ret_len, static void -MHD__asn1_get_objectid_der (const unsigned char *der, int der_len, int *ret_len, - char *str, int str_size) +MHD__asn1_get_objectid_der (const unsigned char *der, int der_len, + int *ret_len, char *str, int str_size) { int len_len, len, k; char temp[20]; @@ -286,8 +288,8 @@ MHD__asn1_get_objectid_der (const unsigned char *der, int der_len, int *ret_len, **/ int MHD__asn1_get_bit_der (const unsigned char *der, int der_len, - int *ret_len, unsigned char *str, int str_size, - int *bit_len) + int *ret_len, unsigned char *str, int str_size, + int *bit_len) { int len_len, len_byte; @@ -314,8 +316,8 @@ MHD__asn1_get_bit_der (const unsigned char *der, int der_len, static int -MHD__asn1_extract_tag_der (node_asn * node, const unsigned char *der, int der_len, - int *ret_len) +MHD__asn1_extract_tag_der (node_asn * node, const unsigned char *der, + int der_len, int *ret_len) { node_asn *p; int counter, len2, len3, is_tag_implicit; @@ -353,8 +355,8 @@ MHD__asn1_extract_tag_der (node_asn * node, const unsigned char *der, int der_le return ASN1_DER_ERROR; counter += len2; len3 = - MHD__asn1_get_length_der (der + counter, der_len - counter, - &len2); + MHD__asn1_get_length_der (der + counter, + der_len - counter, &len2); if (len3 < 0) return ASN1_DER_ERROR; counter += len2; @@ -567,7 +569,8 @@ MHD__asn1_delete_not_used (node_asn * node) static MHD__asn1_retCode -MHD__asn1_get_octet_string (const unsigned char *der, node_asn * node, int *len) +MHD__asn1_get_octet_string (const unsigned char *der, node_asn * node, + int *len) { int len2, len3, counter, counter2, counter_end, tot_len, indefinite; unsigned char *temp, *temp2; @@ -606,7 +609,8 @@ MHD__asn1_get_octet_string (const unsigned char *der, node_asn * node, int *len) counter++; - len2 = MHD__asn1_get_length_der (der + counter, *len - counter, &len3); + len2 = + MHD__asn1_get_length_der (der + counter, *len - counter, &len3); if (len2 <= 0) return ASN1_DER_ERROR; @@ -629,10 +633,10 @@ MHD__asn1_get_octet_string (const unsigned char *der, node_asn * node, int *len) temp2 = temp + len2; len2 = MHD__asn1_get_length_der (der, *len, &len3); if (len2 < -1) - { - MHD__asn1_afree (temp); - return ASN1_DER_ERROR; - } + { + MHD__asn1_afree (temp); + return ASN1_DER_ERROR; + } counter2 = len3 + 1; if (indefinite == -1) @@ -643,12 +647,13 @@ MHD__asn1_get_octet_string (const unsigned char *der, node_asn * node, int *len) while (counter2 < counter_end) { len2 = - MHD__asn1_get_length_der (der + counter2, *len - counter, &len3); + MHD__asn1_get_length_der (der + counter2, *len - counter, + &len3); if (len2 < -1) - { - MHD__asn1_afree (temp); - return ASN1_DER_ERROR; - } + { + MHD__asn1_afree (temp); + return ASN1_DER_ERROR; + } /* FIXME: to be checked. Is this ok? Has the * size been checked before? @@ -757,7 +762,7 @@ MHD__asn1_get_indefinite_length_string (const unsigned char *der, int *len) MHD__asn1_retCode MHD__asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len, - char *errorDescription) + char *errorDescription) { node_asn *node, *p, *p2, *p3; char temp[128]; @@ -789,7 +794,7 @@ MHD__asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len, if (p->type & CONST_SET) { p2 = MHD__asn1_find_up (p); - len2 = strtol ((const char*) p2->value, NULL, 10); + len2 = strtol ((const char *) p2->value, NULL, 10); if (len2 == -1) { if (!der[counter] && !der[counter + 1]) @@ -819,7 +824,7 @@ MHD__asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len, if (type_field (p2->type) != TYPE_CHOICE) ris = MHD__asn1_extract_tag_der (p2, der + counter, - len - counter, &len2); + len - counter, &len2); else { p3 = p2->down; @@ -827,7 +832,8 @@ MHD__asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len, { ris = MHD__asn1_extract_tag_der (p3, der + counter, - len - counter, &len2); + len - counter, + &len2); if (ris == ASN1_SUCCESS) break; p3 = p3->right; @@ -852,7 +858,7 @@ MHD__asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len, if ((p->type & CONST_OPTION) || (p->type & CONST_DEFAULT)) { p2 = MHD__asn1_find_up (p); - len2 = strtol ((const char*) p2->value, NULL, 10); + len2 = strtol ((const char *) p2->value, NULL, 10); if (counter == len2) { if (p->right) @@ -878,7 +884,7 @@ MHD__asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len, if (counter < len) ris = MHD__asn1_extract_tag_der (p->down, der + counter, - len - counter, &len2); + len - counter, &len2); else ris = ASN1_DER_ERROR; if (ris == ASN1_SUCCESS) @@ -917,14 +923,15 @@ MHD__asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len, if ((p->type & CONST_OPTION) || (p->type & CONST_DEFAULT)) { p2 = MHD__asn1_find_up (p); - len2 = strtol ((const char*) p2->value, NULL, 10); + len2 = strtol ((const char *) p2->value, NULL, 10); if ((len2 != -1) && (counter > len2)) ris = ASN1_TAG_ERROR; } if (ris == ASN1_SUCCESS) ris = - MHD__asn1_extract_tag_der (p, der + counter, len - counter, &len2); + MHD__asn1_extract_tag_der (p, der + counter, len - counter, + &len2); if (ris != ASN1_SUCCESS) { if (p->type & CONST_OPTION) @@ -940,7 +947,8 @@ MHD__asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len, else { if (errorDescription != NULL) - MHD__asn1_error_description_tag_error (p, errorDescription); + MHD__asn1_error_description_tag_error (p, + errorDescription); MHD__asn1_delete_structure (element); return ASN1_TAG_ERROR; @@ -978,7 +986,8 @@ MHD__asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len, case TYPE_INTEGER: case TYPE_ENUMERATED: len2 = - MHD__asn1_get_length_der (der + counter, len - counter, &len3); + MHD__asn1_get_length_der (der + counter, len - counter, + &len3); if (len2 < 0) return ASN1_DER_ERROR; if (len2 + len3 > len - counter) @@ -989,7 +998,7 @@ MHD__asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len, break; case TYPE_OBJECT_ID: MHD__asn1_get_objectid_der (der + counter, len - counter, &len2, - temp, sizeof (temp)); + temp, sizeof (temp)); tlen = strlen (temp); if (tlen > 0) MHD__asn1_set_value (p, temp, tlen + 1); @@ -998,8 +1007,8 @@ MHD__asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len, break; case TYPE_TIME: result = - MHD__asn1_get_time_der (der + counter, len - counter, &len2, temp, - sizeof (temp) - 1); + MHD__asn1_get_time_der (der + counter, len - counter, &len2, + temp, sizeof (temp) - 1); if (result != ASN1_SUCCESS) { MHD__asn1_delete_structure (element); @@ -1021,7 +1030,8 @@ MHD__asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len, break; case TYPE_GENERALSTRING: len2 = - MHD__asn1_get_length_der (der + counter, len - counter, &len3); + MHD__asn1_get_length_der (der + counter, len - counter, + &len3); if (len2 < 0) return ASN1_DER_ERROR; if (len3 + len2 > len - counter) @@ -1032,7 +1042,8 @@ MHD__asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len, break; case TYPE_BIT_STRING: len2 = - MHD__asn1_get_length_der (der + counter, len - counter, &len3); + MHD__asn1_get_length_der (der + counter, len - counter, + &len3); if (len2 < 0) return ASN1_DER_ERROR; if (len3 + len2 > len - counter) @@ -1045,7 +1056,7 @@ MHD__asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len, case TYPE_SET: if (move == UP) { - len2 = strtol ( (const char*) p->value, NULL, 10); + len2 = strtol ((const char *) p->value, NULL, 10); MHD__asn1_set_value (p, NULL, 0); if (len2 == -1) { /* indefinite length method */ @@ -1074,7 +1085,8 @@ MHD__asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len, else { /* move==DOWN || move==RIGHT */ len3 = - MHD__asn1_get_length_der (der + counter, len - counter, &len2); + MHD__asn1_get_length_der (der + counter, len - counter, + &len2); if (len3 < -1) return ASN1_DER_ERROR; counter += len2; @@ -1113,7 +1125,7 @@ MHD__asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len, case TYPE_SET_OF: if (move == UP) { - len2 = strtol ( (const char*) p->value, NULL, 10); + len2 = strtol ((const char *) p->value, NULL, 10); if (len2 == -1) { /* indefinite length method */ if ((counter + 2) > len) @@ -1152,7 +1164,8 @@ MHD__asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len, else { /* move==DOWN || move==RIGHT */ len3 = - MHD__asn1_get_length_der (der + counter, len - counter, &len2); + MHD__asn1_get_length_der (der + counter, len - counter, + &len2); if (len3 < -1) return ASN1_DER_ERROR; counter += len2; @@ -1190,7 +1203,7 @@ MHD__asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len, return ASN1_DER_ERROR; len4 = MHD__asn1_get_length_der (der + counter + len2, - len - counter - len2, &len3); + len - counter - len2, &len3); if (len4 < -1) return ASN1_DER_ERROR; if (len4 > len - counter + len2 + len3) @@ -1199,14 +1212,16 @@ MHD__asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len, { len2 += len4; MHD__asn1_length_der (len2 + len3, NULL, &len4); - temp2 = (unsigned char *) MHD__asn1_alloca (len2 + len3 + len4); + temp2 = + (unsigned char *) MHD__asn1_alloca (len2 + len3 + len4); if (temp2 == NULL) { MHD__asn1_delete_structure (element); return ASN1_MEM_ALLOC_ERROR; } - MHD__asn1_octet_der (der + counter, len2 + len3, temp2, &len4); + MHD__asn1_octet_der (der + counter, len2 + len3, temp2, + &len4); MHD__asn1_set_value (p, temp2, len4); MHD__asn1_afree (temp2); counter += len2 + len3; @@ -1221,7 +1236,8 @@ MHD__asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len, len2 = len - counter; ris = - MHD__asn1_get_indefinite_length_string (der + counter, &len2); + MHD__asn1_get_indefinite_length_string (der + counter, + &len2); if (ris != ASN1_SUCCESS) { MHD__asn1_delete_structure (element); @@ -1328,7 +1344,8 @@ MHD__asn1_der_decoding (ASN1_TYPE * element, const void *ider, int len, **/ MHD__asn1_retCode MHD__asn1_der_decoding_startEnd (ASN1_TYPE element, const void *ider, int len, - const char *name_element, int *start, int *end) + const char *name_element, int *start, + int *end) { node_asn *node, *node_to_find, *p, *p2, *p3; int counter, len2, len3, len4, move, ris; @@ -1369,7 +1386,7 @@ MHD__asn1_der_decoding_startEnd (ASN1_TYPE element, const void *ider, int len, if (p->type & CONST_SET) { p2 = MHD__asn1_find_up (p); - len2 = strtol ( (const char* ) p2->value, NULL, 10); + len2 = strtol ((const char *) p2->value, NULL, 10); if (len2 == -1) { if (!der[counter] && !der[counter + 1]) @@ -1396,13 +1413,13 @@ MHD__asn1_der_decoding_startEnd (ASN1_TYPE element, const void *ider, int len, if (type_field (p2->type) != TYPE_CHOICE) ris = MHD__asn1_extract_tag_der (p2, der + counter, - len - counter, &len2); + len - counter, &len2); else { p3 = p2->down; ris = MHD__asn1_extract_tag_der (p3, der + counter, - len - counter, &len2); + len - counter, &len2); } if (ris == ASN1_SUCCESS) { @@ -1425,14 +1442,15 @@ MHD__asn1_der_decoding_startEnd (ASN1_TYPE element, const void *ider, int len, p = p->down; ris = MHD__asn1_extract_tag_der (p, der + counter, len - counter, - &len2); + &len2); if (p == node_to_find) *start = counter; } if (ris == ASN1_SUCCESS) ris = - MHD__asn1_extract_tag_der (p, der + counter, len - counter, &len2); + MHD__asn1_extract_tag_der (p, der + counter, len - counter, + &len2); if (ris != ASN1_SUCCESS) { if (p->type & CONST_OPTION) @@ -1472,7 +1490,8 @@ MHD__asn1_der_decoding_startEnd (ASN1_TYPE element, const void *ider, int len, case TYPE_INTEGER: case TYPE_ENUMERATED: len2 = - MHD__asn1_get_length_der (der + counter, len - counter, &len3); + MHD__asn1_get_length_der (der + counter, len - counter, + &len3); if (len2 < 0) return ASN1_DER_ERROR; counter += len3 + len2; @@ -1480,7 +1499,8 @@ MHD__asn1_der_decoding_startEnd (ASN1_TYPE element, const void *ider, int len, break; case TYPE_OBJECT_ID: len2 = - MHD__asn1_get_length_der (der + counter, len - counter, &len3); + MHD__asn1_get_length_der (der + counter, len - counter, + &len3); if (len2 < 0) return ASN1_DER_ERROR; counter += len2 + len3; @@ -1488,7 +1508,8 @@ MHD__asn1_der_decoding_startEnd (ASN1_TYPE element, const void *ider, int len, break; case TYPE_TIME: len2 = - MHD__asn1_get_length_der (der + counter, len - counter, &len3); + MHD__asn1_get_length_der (der + counter, len - counter, + &len3); if (len2 < 0) return ASN1_DER_ERROR; counter += len2 + len3; @@ -1504,7 +1525,8 @@ MHD__asn1_der_decoding_startEnd (ASN1_TYPE element, const void *ider, int len, break; case TYPE_GENERALSTRING: len2 = - MHD__asn1_get_length_der (der + counter, len - counter, &len3); + MHD__asn1_get_length_der (der + counter, len - counter, + &len3); if (len2 < 0) return ASN1_DER_ERROR; counter += len3 + len2; @@ -1512,7 +1534,8 @@ MHD__asn1_der_decoding_startEnd (ASN1_TYPE element, const void *ider, int len, break; case TYPE_BIT_STRING: len2 = - MHD__asn1_get_length_der (der + counter, len - counter, &len3); + MHD__asn1_get_length_der (der + counter, len - counter, + &len3); if (len2 < 0) return ASN1_DER_ERROR; counter += len3 + len2; @@ -1523,7 +1546,8 @@ MHD__asn1_der_decoding_startEnd (ASN1_TYPE element, const void *ider, int len, if (move != UP) { len3 = - MHD__asn1_get_length_der (der + counter, len - counter, &len2); + MHD__asn1_get_length_der (der + counter, len - counter, + &len2); if (len3 < -1) return ASN1_DER_ERROR; counter += len2; @@ -1544,7 +1568,8 @@ MHD__asn1_der_decoding_startEnd (ASN1_TYPE element, const void *ider, int len, if (move != UP) { len3 = - MHD__asn1_get_length_der (der + counter, len - counter, &len2); + MHD__asn1_get_length_der (der + counter, len - counter, + &len2); if (len3 < -1) return ASN1_DER_ERROR; counter += len2; @@ -1576,7 +1601,7 @@ MHD__asn1_der_decoding_startEnd (ASN1_TYPE element, const void *ider, int len, len4 = MHD__asn1_get_length_der (der + counter + len2, - len - counter - len2, &len3); + len - counter - len2, &len3); if (len4 < -1) return ASN1_DER_ERROR; @@ -1594,7 +1619,8 @@ MHD__asn1_der_decoding_startEnd (ASN1_TYPE element, const void *ider, int len, len2 = len - counter; ris = - MHD__asn1_get_indefinite_length_string (der + counter, &len2); + MHD__asn1_get_indefinite_length_string (der + counter, + &len2); if (ris != ASN1_SUCCESS) return ris; counter += len2; @@ -1646,5 +1672,3 @@ MHD__asn1_der_decoding_startEnd (ASN1_TYPE element, const void *ider, int len, return ASN1_ELEMENT_NOT_FOUND; } - - diff --git a/src/daemon/https/minitasn1/element.c b/src/daemon/https/minitasn1/element.c @@ -76,7 +76,7 @@ MHD__asn1_hierarchical_name (node_asn * node, char *name, int name_size) /******************************************************************/ MHD__asn1_retCode MHD__asn1_convert_integer (const char *value, unsigned char *value_out, - int value_out_size, int *len) + int value_out_size, int *len) { char negative; unsigned char val[SIZEOF_UNSIGNED_LONG_INT]; @@ -117,7 +117,8 @@ MHD__asn1_convert_integer (const char *value, unsigned char *value_out, #ifdef LIBTASN1_DEBUG_INTEGER - MHD__libtasn1_log ("MHD__asn1_convert_integer: valueIn=%s, lenOut=%d", value, *len); + MHD__libtasn1_log ("MHD__asn1_convert_integer: valueIn=%s, lenOut=%d", + value, *len); for (k = 0; k < SIZEOF_UNSIGNED_LONG_INT; k++) MHD__libtasn1_log (", vOut[%d]=%d", k, value_out[k]); MHD__libtasn1_log ("\n"); @@ -276,7 +277,7 @@ MHD__asn1_append_sequence_set (node_asn * node) **/ MHD__asn1_retCode MHD__asn1_write_value (ASN1_TYPE node_root, const char *name, - const void *ivalue, int len) + const void *ivalue, int len) { node_asn *node, *p, *p2; unsigned char *temp, *value_temp = NULL, *default_temp = NULL; @@ -355,7 +356,7 @@ MHD__asn1_write_value (ASN1_TYPE node_root, const char *name, return ASN1_MEM_ALLOC_ERROR; MHD__asn1_convert_integer (value, value_temp, - SIZEOF_UNSIGNED_LONG_INT, &len); + SIZEOF_UNSIGNED_LONG_INT, &len); } else { /* is an identifier like v1 */ @@ -374,10 +375,10 @@ MHD__asn1_write_value (ASN1_TYPE node_root, const char *name, if (value_temp == NULL) return ASN1_MEM_ALLOC_ERROR; - MHD__asn1_convert_integer ((const char*) p->value, - value_temp, - SIZEOF_UNSIGNED_LONG_INT, - &len); + MHD__asn1_convert_integer ((const char *) p->value, + value_temp, + SIZEOF_UNSIGNED_LONG_INT, + &len); break; } } @@ -420,10 +421,10 @@ MHD__asn1_write_value (ASN1_TYPE node_root, const char *name, MHD__asn1_length_der (len - k, NULL, &len2); temp = (unsigned char *) MHD__asn1_alloca (len - k + len2); if (temp == NULL) - { - MHD__asn1_afree (value_temp); - return ASN1_MEM_ALLOC_ERROR; - } + { + MHD__asn1_afree (value_temp); + return ASN1_MEM_ALLOC_ERROR; + } MHD__asn1_octet_der (value_temp + k, len - k, temp, &len2); MHD__asn1_set_value (node, temp, len2); @@ -441,51 +442,53 @@ MHD__asn1_write_value (ASN1_TYPE node_root, const char *name, default_temp = (unsigned char *) MHD__asn1_alloca (SIZEOF_UNSIGNED_LONG_INT); if (default_temp == NULL) - { - MHD__asn1_afree (value_temp); - return ASN1_MEM_ALLOC_ERROR; - } + { + MHD__asn1_afree (value_temp); + return ASN1_MEM_ALLOC_ERROR; + } - MHD__asn1_convert_integer ((const char*) p->value, default_temp, - SIZEOF_UNSIGNED_LONG_INT, &len2); + MHD__asn1_convert_integer ((const char *) p->value, + default_temp, + SIZEOF_UNSIGNED_LONG_INT, &len2); } else { /* is an identifier like v1 */ if (!(node->type & CONST_LIST)) - { - MHD__asn1_afree (value_temp); - return ASN1_VALUE_NOT_VALID; - } + { + MHD__asn1_afree (value_temp); + return ASN1_VALUE_NOT_VALID; + } p2 = node->down; while (p2) { if (type_field (p2->type) == TYPE_CONSTANT) { - if ((p2->name) && (!strcmp (p2->name,(const char*) p->value))) + if ((p2->name) + && (!strcmp (p2->name, (const char *) p->value))) { default_temp = (unsigned char *) MHD__asn1_alloca (SIZEOF_UNSIGNED_LONG_INT); if (default_temp == NULL) - { - MHD__asn1_afree (value_temp); - return ASN1_MEM_ALLOC_ERROR; - } - - MHD__asn1_convert_integer ((const char*) p2->value, - default_temp, - SIZEOF_UNSIGNED_LONG_INT, - &len2); + { + MHD__asn1_afree (value_temp); + return ASN1_MEM_ALLOC_ERROR; + } + + MHD__asn1_convert_integer ((const char *) p2->value, + default_temp, + SIZEOF_UNSIGNED_LONG_INT, + &len2); break; } } p2 = p2->right; } if (p2 == NULL) - { - MHD__asn1_afree (value_temp); - return ASN1_VALUE_NOT_VALID; - } + { + MHD__asn1_afree (value_temp); + return ASN1_VALUE_NOT_VALID; + } } @@ -512,7 +515,7 @@ MHD__asn1_write_value (ASN1_TYPE node_root, const char *name, p = node->down; while (type_field (p->type) != TYPE_DEFAULT) p = p->right; - if (!strcmp (value,(const char*) p->value)) + if (!strcmp (value, (const char *) p->value)) { MHD__asn1_set_value (node, NULL, 0); break; @@ -574,7 +577,7 @@ MHD__asn1_write_value (ASN1_TYPE node_root, const char *name, if (temp == NULL) return ASN1_MEM_ALLOC_ERROR; - MHD__asn1_octet_der ((const unsigned char*) value, len, temp, &len2); + MHD__asn1_octet_der ((const unsigned char *) value, len, temp, &len2); MHD__asn1_set_value (node, temp, len2); MHD__asn1_afree (temp); break; @@ -586,7 +589,7 @@ MHD__asn1_write_value (ASN1_TYPE node_root, const char *name, if (temp == NULL) return ASN1_MEM_ALLOC_ERROR; - MHD__asn1_octet_der ((const unsigned char*)value, len, temp, &len2); + MHD__asn1_octet_der ((const unsigned char *) value, len, temp, &len2); MHD__asn1_set_value (node, temp, len2); MHD__asn1_afree (temp); break; @@ -598,7 +601,7 @@ MHD__asn1_write_value (ASN1_TYPE node_root, const char *name, if (temp == NULL) return ASN1_MEM_ALLOC_ERROR; - MHD__asn1_bit_der ((const unsigned char*)value, len, temp, &len2); + MHD__asn1_bit_der ((const unsigned char *) value, len, temp, &len2); MHD__asn1_set_value (node, temp, len2); MHD__asn1_afree (temp); break; @@ -632,7 +635,7 @@ MHD__asn1_write_value (ASN1_TYPE node_root, const char *name, if (temp == NULL) return ASN1_MEM_ALLOC_ERROR; - MHD__asn1_octet_der ((const unsigned char*)value, len, temp, &len2); + MHD__asn1_octet_der ((const unsigned char *) value, len, temp, &len2); MHD__asn1_set_value (node, temp, len2); MHD__asn1_afree (temp); break; @@ -744,7 +747,8 @@ MHD__asn1_write_value (ASN1_TYPE node_root, const char *name, * **/ MHD__asn1_retCode -MHD__asn1_read_value (ASN1_TYPE root, const char *name, void *ivalue, int *len) +MHD__asn1_read_value (ASN1_TYPE root, const char *name, void *ivalue, + int *len) { node_asn *node, *p, *p2; int len2, len3; @@ -801,7 +805,8 @@ MHD__asn1_read_value (ASN1_TYPE root, const char *name, void *ivalue, int *len) || (p->value[0] == '+')) { if (MHD__asn1_convert_integer - ((const char*) p->value, (unsigned char*) value, value_size, len) != ASN1_SUCCESS) + ((const char *) p->value, (unsigned char *) value, + value_size, len) != ASN1_SUCCESS) return ASN1_MEM_ERROR; } else @@ -811,10 +816,12 @@ MHD__asn1_read_value (ASN1_TYPE root, const char *name, void *ivalue, int *len) { if (type_field (p2->type) == TYPE_CONSTANT) { - if ((p2->name) && (!strcmp (p2->name, (const char*) p->value))) + if ((p2->name) + && (!strcmp (p2->name, (const char *) p->value))) { if (MHD__asn1_convert_integer - ((const char*) p2->value, (unsigned char*) value, value_size, + ((const char *) p2->value, + (unsigned char *) value, value_size, len) != ASN1_SUCCESS) return ASN1_MEM_ERROR; break; @@ -828,8 +835,8 @@ MHD__asn1_read_value (ASN1_TYPE root, const char *name, void *ivalue, int *len) { len2 = -1; if (MHD__asn1_get_octet_der - (node->value, node->value_len, &len2, (unsigned char*) value, value_size, - len) != ASN1_SUCCESS) + (node->value, node->value_len, &len2, (unsigned char *) value, + value_size, len) != ASN1_SUCCESS) return ASN1_MEM_ERROR; } break; @@ -842,7 +849,7 @@ MHD__asn1_read_value (ASN1_TYPE root, const char *name, void *ivalue, int *len) { if (type_field (p->type) == TYPE_CONSTANT) { - ADD_STR_VALUE (value, value_size, (const char*) p->value); + ADD_STR_VALUE (value, value_size, (const char *) p->value); if (p->right) { ADD_STR_VALUE (value, value_size, "."); @@ -857,35 +864,35 @@ MHD__asn1_read_value (ASN1_TYPE root, const char *name, void *ivalue, int *len) p = node->down; while (type_field (p->type) != TYPE_DEFAULT) p = p->right; - PUT_STR_VALUE (value, value_size, (const char*) p->value); + PUT_STR_VALUE (value, value_size, (const char *) p->value); } else { - PUT_STR_VALUE (value, value_size, (const char*) node->value); + PUT_STR_VALUE (value, value_size, (const char *) node->value); } break; case TYPE_TIME: - PUT_STR_VALUE (value, value_size, (const char*) node->value); + PUT_STR_VALUE (value, value_size, (const char *) node->value); break; case TYPE_OCTET_STRING: len2 = -1; if (MHD__asn1_get_octet_der - (node->value, node->value_len, &len2, (unsigned char*) value, value_size, - len) != ASN1_SUCCESS) + (node->value, node->value_len, &len2, (unsigned char *) value, + value_size, len) != ASN1_SUCCESS) return ASN1_MEM_ERROR; break; case TYPE_GENERALSTRING: len2 = -1; if (MHD__asn1_get_octet_der - (node->value, node->value_len, &len2, (unsigned char*) value, value_size, - len) != ASN1_SUCCESS) + (node->value, node->value_len, &len2, (unsigned char *) value, + value_size, len) != ASN1_SUCCESS) return ASN1_MEM_ERROR; break; case TYPE_BIT_STRING: len2 = -1; if (MHD__asn1_get_bit_der - (node->value, node->value_len, &len2, (unsigned char*) value, value_size, - len) != ASN1_SUCCESS) + (node->value, node->value_len, &len2, (unsigned char *) value, + value_size, len) != ASN1_SUCCESS) return ASN1_MEM_ERROR; break; case TYPE_CHOICE: @@ -904,5 +911,3 @@ MHD__asn1_read_value (ASN1_TYPE root, const char *name, void *ivalue, int *len) } return ASN1_SUCCESS; } - - diff --git a/src/daemon/https/minitasn1/element.h b/src/daemon/https/minitasn1/element.h @@ -6,8 +6,8 @@ MHD__asn1_retCode MHD__asn1_append_sequence_set (node_asn * node); MHD__asn1_retCode MHD__asn1_convert_integer (const char *value, - unsigned char *value_out, - int value_out_size, int *len); + unsigned char *value_out, + int value_out_size, int *len); void MHD__asn1_hierarchical_name (node_asn * node, char *name, int name_size); diff --git a/src/daemon/https/minitasn1/libtasn1.h b/src/daemon/https/minitasn1/libtasn1.h @@ -43,7 +43,7 @@ extern "C" /* (null character included) */ - typedef int MHD__asn1_retCode; /* type returned by libtasn1 functions */ + typedef int MHD__asn1_retCode; /* type returned by libtasn1 functions */ /*****************************************/ /* Errors returned by libtasn1 functions */ @@ -138,49 +138,53 @@ extern "C" /***********************************/ MHD__asn1_retCode MHD__asn1_parser2tree (const char *file_name, - ASN1_TYPE * definitions, - char *errorDescription); + ASN1_TYPE * definitions, + char *errorDescription); MHD__asn1_retCode MHD__asn1_parser2array (const char *inputFileName, - const char *outputFileName, - const char *vectorName, - char *errorDescription); + const char *outputFileName, + const char *vectorName, + char *errorDescription); MHD__asn1_retCode MHD__asn1_array2tree (const ASN1_ARRAY_TYPE * array, - ASN1_TYPE * definitions, - char *errorDescription); + ASN1_TYPE * definitions, + char *errorDescription); MHD__asn1_retCode MHD__asn1_create_element (ASN1_TYPE definitions, - const char *source_name, - ASN1_TYPE * element); + const char *source_name, + ASN1_TYPE * element); MHD__asn1_retCode MHD__asn1_delete_structure (ASN1_TYPE * structure); MHD__asn1_retCode MHD__asn1_delete_element (ASN1_TYPE structure, - const char *element_name); + const char *element_name); - MHD__asn1_retCode MHD__asn1_write_value (ASN1_TYPE node_root, const char *name, - const void *ivalue, int len); + MHD__asn1_retCode MHD__asn1_write_value (ASN1_TYPE node_root, + const char *name, + const void *ivalue, int len); MHD__asn1_retCode MHD__asn1_read_value (ASN1_TYPE root, const char *name, - void *ivalue, int *len); + void *ivalue, int *len); - MHD__asn1_retCode MHD__asn1_number_of_elements (ASN1_TYPE element, const char *name, - int *num); + MHD__asn1_retCode MHD__asn1_number_of_elements (ASN1_TYPE element, + const char *name, int *num); MHD__asn1_retCode MHD__asn1_der_coding (ASN1_TYPE element, const char *name, - void *ider, int *len, char *ErrorDescription); + void *ider, int *len, + char *ErrorDescription); - MHD__asn1_retCode MHD__asn1_der_decoding (ASN1_TYPE * element, const void *ider, - int len, char *errorDescription); + MHD__asn1_retCode MHD__asn1_der_decoding (ASN1_TYPE * element, + const void *ider, int len, + char *errorDescription); MHD__asn1_retCode MHD__asn1_der_decoding_startEnd (ASN1_TYPE element, - const void *ider, int len, - const char *name_element, - int *start, int *end); + const void *ider, + int len, + const char *name_element, + int *start, int *end); const char *MHD__asn1_find_structure_from_oid (ASN1_TYPE definitions, - const char *oidValue); + const char *oidValue); const char *MHD__libtasn1_strerror (MHD__asn1_retCode error); @@ -189,34 +193,37 @@ extern "C" /* DER utility functions. */ int MHD__asn1_get_tag_der (const unsigned char *der, int der_len, - unsigned char *cls, int *len, unsigned long *tag); + unsigned char *cls, int *len, + unsigned long *tag); void MHD__asn1_octet_der (const unsigned char *str, int str_len, - unsigned char *der, int *der_len); + unsigned char *der, int *der_len); - MHD__asn1_retCode MHD__asn1_get_octet_der (const unsigned char *der, int der_len, - int *ret_len, unsigned char *str, - int str_size, int *str_len); + MHD__asn1_retCode MHD__asn1_get_octet_der (const unsigned char *der, + int der_len, int *ret_len, + unsigned char *str, int str_size, + int *str_len); void MHD__asn1_bit_der (const unsigned char *str, int bit_len, - unsigned char *der, int *der_len); + unsigned char *der, int *der_len); - MHD__asn1_retCode MHD__asn1_get_bit_der (const unsigned char *der, int der_len, - int *ret_len, unsigned char *str, - int str_size, int *bit_len); + MHD__asn1_retCode MHD__asn1_get_bit_der (const unsigned char *der, + int der_len, int *ret_len, + unsigned char *str, int str_size, + int *bit_len); signed long MHD__asn1_get_length_der (const unsigned char *der, int der_len, - int *len); + int *len); void MHD__asn1_length_der (unsigned long int len, unsigned char *ans, - int *ans_len); + int *ans_len); /* Other utility functions. */ ASN1_TYPE MHD__asn1_find_node (ASN1_TYPE pointer, const char *name); MHD__asn1_retCode MHD__asn1_copy_node (ASN1_TYPE dst, const char *dst_name, - ASN1_TYPE src, const char *src_name); + ASN1_TYPE src, const char *src_name); #ifdef __cplusplus } diff --git a/src/daemon/https/minitasn1/parser_aux.c b/src/daemon/https/minitasn1/parser_aux.c @@ -29,7 +29,7 @@ -char MHD__asn1_identifierMissing[MAX_NAME_SIZE + 1]; /* identifier name not found */ +char MHD__asn1_identifierMissing[MAX_NAME_SIZE + 1]; /* identifier name not found */ /***********************************************/ /* Type: list_type */ @@ -443,7 +443,8 @@ MHD__asn1_change_integer_value (ASN1_TYPE node) { if (p->value) { - MHD__asn1_convert_integer ((const char*) p->value, val, sizeof (val), &len); + MHD__asn1_convert_integer ((const char *) p->value, val, + sizeof (val), &len); MHD__asn1_octet_der (val, len, val2, &len); MHD__asn1_set_value (p, val2, len); } @@ -521,7 +522,8 @@ MHD__asn1_expand_object_id (ASN1_TYPE node) { MHD__asn1_str_cpy (name2, sizeof (name2), name_root); MHD__asn1_str_cat (name2, sizeof (name2), "."); - MHD__asn1_str_cat (name2, sizeof (name2), (const char*) p2->value); + MHD__asn1_str_cat (name2, sizeof (name2), + (const char *) p2->value); p3 = MHD__asn1_find_node (node, name2); if (!p3 || (type_field (p3->type) != TYPE_OBJECT_ID) || !(p3->type & CONST_ASSIGN)) @@ -536,7 +538,7 @@ MHD__asn1_expand_object_id (ASN1_TYPE node) { p5 = MHD__asn1_add_node_only (TYPE_CONSTANT); MHD__asn1_set_name (p5, p4->name); - tlen = strlen ( (const char*) p4->value); + tlen = strlen ((const char *) p4->value); if (tlen > 0) MHD__asn1_set_value (p5, p4->value, tlen + 1); if (p2 == p) @@ -607,7 +609,8 @@ MHD__asn1_expand_object_id (ASN1_TYPE node) { MHD__asn1_str_cpy (name2, sizeof (name2), name_root); MHD__asn1_str_cat (name2, sizeof (name2), "."); - MHD__asn1_str_cat (name2, sizeof (name2), (const char*) p2->value); + MHD__asn1_str_cat (name2, sizeof (name2), + (const char *) p2->value); p3 = MHD__asn1_find_node (node, name2); if (!p3 || (type_field (p3->type) != TYPE_OBJECT_ID) || !(p3->type & CONST_ASSIGN)) @@ -620,7 +623,8 @@ MHD__asn1_expand_object_id (ASN1_TYPE node) { if (name2[0]) MHD__asn1_str_cat (name2, sizeof (name2), "."); - MHD__asn1_str_cat (name2, sizeof (name2), (const char*) p4->value); + MHD__asn1_str_cat (name2, sizeof (name2), + (const char *) p4->value); } p4 = p4->right; } @@ -691,11 +695,11 @@ MHD__asn1_check_identifier (ASN1_TYPE node) { MHD__asn1_str_cpy (name2, sizeof (name2), node->name); MHD__asn1_str_cat (name2, sizeof (name2), "."); - MHD__asn1_str_cat (name2, sizeof (name2), (const char*) p->value); + MHD__asn1_str_cat (name2, sizeof (name2), (const char *) p->value); p2 = MHD__asn1_find_node (node, name2); if (p2 == NULL) { - strcpy (MHD__asn1_identifierMissing, (const char*) p->value); + strcpy (MHD__asn1_identifierMissing, (const char *) p->value); return ASN1_IDENTIFIER_NOT_FOUND; } } @@ -707,8 +711,9 @@ MHD__asn1_check_identifier (ASN1_TYPE node) { MHD__asn1_str_cpy (name2, sizeof (name2), node->name); MHD__asn1_str_cat (name2, sizeof (name2), "."); - MHD__asn1_str_cat (name2, sizeof (name2), (const char*) p2->value); - strcpy (MHD__asn1_identifierMissing, (const char*) p2->value); + MHD__asn1_str_cat (name2, sizeof (name2), + (const char *) p2->value); + strcpy (MHD__asn1_identifierMissing, (const char *) p2->value); p2 = MHD__asn1_find_node (node, name2); if (!p2 || (type_field (p2->type) != TYPE_OBJECT_ID) || !(p2->type & CONST_ASSIGN)) @@ -727,8 +732,10 @@ MHD__asn1_check_identifier (ASN1_TYPE node) { MHD__asn1_str_cpy (name2, sizeof (name2), node->name); MHD__asn1_str_cat (name2, sizeof (name2), "."); - MHD__asn1_str_cat (name2, sizeof (name2), (const char*) p2->value); - strcpy (MHD__asn1_identifierMissing, (const char*) p2->value); + MHD__asn1_str_cat (name2, sizeof (name2), + (const char *) p2->value); + strcpy (MHD__asn1_identifierMissing, + (const char *) p2->value); p2 = MHD__asn1_find_node (node, name2); if (!p2 || (type_field (p2->type) != TYPE_OBJECT_ID) || !(p2->type & CONST_ASSIGN)) diff --git a/src/daemon/https/minitasn1/parser_aux.h b/src/daemon/https/minitasn1/parser_aux.h @@ -9,7 +9,7 @@ node_asn *MHD__asn1_add_node (unsigned int type); node_asn *MHD__asn1_set_value (node_asn * node, const void *value, - unsigned int len); + unsigned int len); node_asn *MHD__asn1_set_name (node_asn * node, const char *name); diff --git a/src/daemon/https/minitasn1/structure.c b/src/daemon/https/minitasn1/structure.c @@ -37,7 +37,8 @@ extern char MHD__asn1_identifierMissing[]; -static node_asn *MHD__asn1_copy_structure2 (node_asn * root, const char *source_name); +static node_asn *MHD__asn1_copy_structure2 (node_asn * root, + const char *source_name); @@ -106,7 +107,7 @@ MHD__asn1_find_left (node_asn * node) **/ MHD__asn1_retCode MHD__asn1_array2tree (const ASN1_ARRAY_TYPE * array, ASN1_TYPE * definitions, - char *errorDescription) + char *errorDescription) { node_asn *p, *p_last = NULL; unsigned long k; @@ -421,7 +422,7 @@ MHD__asn1_type_choice_config (node_asn * node) if (type_field (p3->type) == TYPE_TAG) { p4 = MHD__asn1_add_node_only (p3->type); - tlen = strlen ((const char*) p3->value); + tlen = strlen ((const char *) p3->value); if (tlen > 0) MHD__asn1_set_value (p4, p3->value, tlen + 1); MHD__asn1_set_right (p4, p2->down); @@ -497,7 +498,8 @@ MHD__asn1_expand_identifier (node_asn ** node, node_asn * root) { MHD__asn1_str_cpy (name2, sizeof (name2), root->name); MHD__asn1_str_cat (name2, sizeof (name2), "."); - MHD__asn1_str_cat (name2, sizeof (name2), (const char*) p->value); + MHD__asn1_str_cat (name2, sizeof (name2), + (const char *) p->value); p2 = MHD__asn1_copy_structure2 (root, name2); if (p2 == NULL) { @@ -606,7 +608,7 @@ MHD__asn1_expand_identifier (node_asn ** node, node_asn * root) **/ MHD__asn1_retCode MHD__asn1_create_element (ASN1_TYPE definitions, const char *source_name, - ASN1_TYPE * element) + ASN1_TYPE * element) { node_asn *dest_node; int res; @@ -685,7 +687,8 @@ MHD__asn1_number_of_elements (ASN1_TYPE element, const char *name, int *num) * **/ const char * -MHD__asn1_find_structure_from_oid (ASN1_TYPE definitions, const char *oidValue) +MHD__asn1_find_structure_from_oid (ASN1_TYPE definitions, + const char *oidValue) { char definitionsName[MAX_NAME_SIZE], name[2 * MAX_NAME_SIZE + 1]; char value[MAX_NAME_SIZE]; @@ -741,7 +744,7 @@ MHD__asn1_find_structure_from_oid (ASN1_TYPE definitions, const char *oidValue) **/ MHD__asn1_retCode MHD__asn1_copy_node (ASN1_TYPE dst, const char *dst_name, - ASN1_TYPE src, const char *src_name) + ASN1_TYPE src, const char *src_name) { /* FIXME: rewrite using copy_structure(). * It seems quite hard to do. diff --git a/src/daemon/https/tls/auth_cert.c b/src/daemon/https/tls/auth_cert.c @@ -45,9 +45,10 @@ #include <gnutls_x509.h> #include "debug.h" -static MHD_gnutls_cert *alloc_and_load_x509_certs (MHD_gnutls_x509_crt_t * certs, - unsigned); -static MHD_gnutls_privkey *alloc_and_load_x509_key (MHD_gnutls_x509_privkey_t key); +static MHD_gnutls_cert *alloc_and_load_x509_certs (MHD_gnutls_x509_crt_t * + certs, unsigned); +static MHD_gnutls_privkey *alloc_and_load_x509_key (MHD_gnutls_x509_privkey_t + key); /* Copies data from a internal certificate struct (MHD_gnutls_cert) to @@ -55,7 +56,7 @@ static MHD_gnutls_privkey *alloc_and_load_x509_key (MHD_gnutls_x509_privkey_t ke */ static int MHD__gnutls_copy_certificate_auth_info (cert_auth_info_t info, - MHD_gnutls_cert * cert, int ncerts) + MHD_gnutls_cert * cert, int ncerts) { /* Copy peer's information to auth_info_t */ @@ -82,7 +83,7 @@ MHD__gnutls_copy_certificate_auth_info (cert_auth_info_t info, { ret = MHD__gnutls_set_datum (&info->raw_certificate_list[i], - cert[i].raw.data, cert[i].raw.size); + cert[i].raw.data, cert[i].raw.size); if (ret < 0) { MHD_gnutls_assert (); @@ -113,9 +114,9 @@ clear: */ inline static int MHD__gnutls_check_pk_algo_in_list (const enum MHD_GNUTLS_PublicKeyAlgorithm - *pk_algos, int pk_algos_length, - enum MHD_GNUTLS_PublicKeyAlgorithm - algo_to_check) + *pk_algos, int pk_algos_length, + enum MHD_GNUTLS_PublicKeyAlgorithm + algo_to_check) { int i; for (i = 0; i < pk_algos_length; i++) @@ -133,7 +134,8 @@ MHD__gnutls_check_pk_algo_in_list (const enum MHD_GNUTLS_PublicKeyAlgorithm * specified in cert. */ static int -MHD__gnutls_cert_get_issuer_dn (MHD_gnutls_cert * cert, MHD_gnutls_datum_t * odn) +MHD__gnutls_cert_get_issuer_dn (MHD_gnutls_cert * cert, + MHD_gnutls_datum_t * odn) { ASN1_TYPE dn; int len, result; @@ -155,8 +157,9 @@ MHD__gnutls_cert_get_issuer_dn (MHD_gnutls_cert * cert, MHD_gnutls_datum_t * odn return MHD_gtls_asn2err (result); } - result = MHD__asn1_der_decoding_startEnd (dn, cert->raw.data, cert->raw.size, - "tbsCertificate.issuer", &start, &end); + result = + MHD__asn1_der_decoding_startEnd (dn, cert->raw.data, cert->raw.size, + "tbsCertificate.issuer", &start, &end); if (result != ASN1_SUCCESS) { @@ -211,7 +214,7 @@ _find_x509_cert (const MHD_gtls_cert_credentials_t cred, { if ((result = MHD__gnutls_cert_get_issuer_dn (&cred->cert_list[i][j], - &odn)) < 0) + &odn)) < 0) { MHD_gnutls_assert (); return result; @@ -483,7 +486,8 @@ _select_client_cert (MHD_gtls_session_t session, if (issuers_dn_length > 0) { issuers_dn = - MHD_gnutls_malloc (sizeof (MHD_gnutls_datum_t) * issuers_dn_length); + MHD_gnutls_malloc (sizeof (MHD_gnutls_datum_t) * + issuers_dn_length); if (issuers_dn == NULL) { MHD_gnutls_assert (); @@ -712,7 +716,8 @@ MHD_gtls_proc_x509_server_certificate (MHD_gtls_session_t session, */ peer_certificate_list = - MHD_gnutls_malloc (sizeof (MHD_gnutls_cert) * (peer_certificate_list_size)); + MHD_gnutls_malloc (sizeof (MHD_gnutls_cert) * + (peer_certificate_list_size)); if (peer_certificate_list == NULL) { @@ -752,8 +757,9 @@ MHD_gtls_proc_x509_server_certificate (MHD_gtls_session_t session, if ((ret = MHD__gnutls_copy_certificate_auth_info (info, - peer_certificate_list, - peer_certificate_list_size)) < 0) + peer_certificate_list, + peer_certificate_list_size)) < + 0) { MHD_gnutls_assert (); goto cleanup; @@ -761,7 +767,7 @@ MHD_gtls_proc_x509_server_certificate (MHD_gtls_session_t session, if ((ret = MHD__gnutls_check_key_usage (&peer_certificate_list[0], - MHD_gnutls_kx_get (session))) < 0) + MHD_gnutls_kx_get (session))) < 0) { MHD_gnutls_assert (); goto cleanup; diff --git a/src/daemon/https/tls/auth_cert.h b/src/daemon/https/tls/auth_cert.h @@ -117,9 +117,9 @@ typedef struct MHD_gtls_cert_auth_info_st MHD_gtls_dh_info_st dh; rsa_info_st rsa_export; - MHD_gnutls_datum_t *raw_certificate_list; /* holds the raw certificate of the - * peer. - */ + MHD_gnutls_datum_t *raw_certificate_list; /* holds the raw certificate of the + * peer. + */ unsigned int ncerts; /* holds the size of the list above */ } *cert_auth_info_t; diff --git a/src/daemon/https/tls/auth_rsa.c b/src/daemon/https/tls/auth_rsa.c @@ -57,7 +57,7 @@ const MHD_gtls_mod_auth_st MHD_gtls_rsa_auth_struct = { MHD_gtls_proc_cert_server_certificate, MHD__gnutls_proc_cert_client_certificate, NULL, /* proc server kx */ - MHD__gnutls_proc_rsa_client_kx, /* proc client kx */ + MHD__gnutls_proc_rsa_client_kx, /* proc client kx */ MHD_gtls_proc_cert_client_cert_vrfy, /* proc client cert vrfy */ MHD_gtls_proc_cert_cert_req /* proc server cert request */ }; @@ -66,8 +66,8 @@ const MHD_gtls_mod_auth_st MHD_gtls_rsa_auth_struct = { */ int MHD__gnutls_get_public_rsa_params (MHD_gtls_session_t session, - mpi_t params[MAX_PUBLIC_PARAMS_SIZE], - int *params_len) + mpi_t params[MAX_PUBLIC_PARAMS_SIZE], + int *params_len) { int ret; cert_auth_info_t info; @@ -148,7 +148,7 @@ MHD__gnutls_get_public_rsa_params (MHD_gtls_session_t session, */ int MHD__gnutls_get_private_rsa_params (MHD_gtls_session_t session, - mpi_t ** params, int *params_size) + mpi_t ** params, int *params_size) { int bits; MHD_gtls_cert_credentials_t cred; @@ -169,8 +169,8 @@ MHD__gnutls_get_private_rsa_params (MHD_gtls_session_t session, } bits = - MHD__gnutls_mpi_get_nbits (session->internals.selected_cert_list[0]. - params[0]); + MHD__gnutls_mpi_get_nbits (session->internals. + selected_cert_list[0].params[0]); if (MHD_gtls_cipher_suite_get_kx_algo (&session->security_parameters.current_cipher_suite) @@ -207,7 +207,7 @@ MHD__gnutls_get_private_rsa_params (MHD_gtls_session_t session, int MHD__gnutls_proc_rsa_client_kx (MHD_gtls_session_t session, opaque * data, - size_t _data_size) + size_t _data_size) { MHD_gnutls_datum_t plaintext; MHD_gnutls_datum_t ciphertext; @@ -291,7 +291,8 @@ MHD__gnutls_proc_rsa_client_kx (MHD_gtls_session_t session, opaque * data, /* we do not need strong random numbers here. */ - if (MHD_gc_nonce ((char*) session->key->key.data, session->key->key.size) != GC_OK) + if (MHD_gc_nonce + ((char *) session->key->key.data, session->key->key.size) != GC_OK) { MHD_gnutls_assert (); return GNUTLS_E_RANDOM_FAILED; @@ -321,7 +322,7 @@ int MHD__gnutls_gen_rsa_client_kx (MHD_gtls_session_t session, opaque ** data) { cert_auth_info_t auth; - MHD_gnutls_datum_t sdata; /* data to send */ + MHD_gnutls_datum_t sdata; /* data to send */ mpi_t params[MAX_PUBLIC_PARAMS_SIZE]; int params_len = MAX_PUBLIC_PARAMS_SIZE; int ret, i; @@ -330,7 +331,7 @@ MHD__gnutls_gen_rsa_client_kx (MHD_gtls_session_t session, opaque ** data) if (session->key == NULL) { MHD_gnutls_assert (); - return GNUTLS_E_INSUFFICIENT_CREDENTIALS; + return GNUTLS_E_INSUFFICIENT_CREDENTIALS; } auth = session->key->auth_info; @@ -352,8 +353,8 @@ MHD__gnutls_gen_rsa_client_kx (MHD_gtls_session_t session, opaque ** data) return GNUTLS_E_MEMORY_ERROR; } - if (MHD_gc_pseudo_random ((char*) session->key->key.data, - session->key->key.size) != GC_OK) + if (MHD_gc_pseudo_random ((char *) session->key->key.data, + session->key->key.size) != GC_OK) { MHD_gnutls_assert (); return GNUTLS_E_RANDOM_FAILED; diff --git a/src/daemon/https/tls/auth_rsa_export.c b/src/daemon/https/tls/auth_rsa_export.c @@ -60,7 +60,7 @@ const MHD_gtls_mod_auth_st MHD_rsa_export_auth_struct = { MHD_gtls_proc_cert_server_certificate, MHD__gnutls_proc_cert_client_certificate, proc_rsa_export_server_kx, - MHD__gnutls_proc_rsa_client_kx, /* proc client kx */ + MHD__gnutls_proc_rsa_client_kx, /* proc client kx */ MHD_gtls_proc_cert_client_cert_vrfy, /* proc client cert vrfy */ MHD_gtls_proc_cert_cert_req /* proc server cert request */ }; diff --git a/src/daemon/https/tls/debug.c b/src/daemon/https/tls/debug.c @@ -37,13 +37,15 @@ MHD__gnutls_print_state (MHD_gtls_session_t session) MHD__gnutls_debug_log ("GNUTLS State:\n"); MHD__gnutls_debug_log ("Connection End: %d\n", - session->security_parameters.entity); + session->security_parameters.entity); MHD__gnutls_debug_log ("Cipher Algorithm: %d\n", - session->security_parameters.read_bulk_cipher_algorithm); + session->security_parameters. + read_bulk_cipher_algorithm); MHD__gnutls_debug_log ("MAC algorithm: %d\n", - session->security_parameters.read_mac_algorithm); + session->security_parameters.read_mac_algorithm); MHD__gnutls_debug_log ("Compression Algorithm: %d\n", - session->security_parameters.read_compression_algorithm); + session->security_parameters. + read_compression_algorithm); MHD__gnutls_debug_log ("\n"); } @@ -123,6 +125,7 @@ MHD__gnutls_dump_mpi (const char *prefix, mpi_t a) size_t n = sizeof buf; if (gcry_mpi_print (GCRYMPI_FMT_HEX, buf, n, &n, a)) - strcpy ((char*) buf, "[can't print value]"); /* Flawfinder: ignore */ - MHD__gnutls_hard_log ("MPI: length: %d\n\t%s%s\n", (n - 1) / 2, prefix, buf); + strcpy ((char *) buf, "[can't print value]"); /* Flawfinder: ignore */ + MHD__gnutls_hard_log ("MPI: length: %d\n\t%s%s\n", (n - 1) / 2, prefix, + buf); } diff --git a/src/daemon/https/tls/debug.h b/src/daemon/https/tls/debug.h @@ -26,5 +26,6 @@ void MHD__gnutls_print_state (MHD_gtls_session_t session); #endif const char *MHD__gnutls_packet2str (content_type_t packet); -const char *MHD__gnutls_handshake2str (MHD_gnutls_handshake_description_t handshake); +const char *MHD__gnutls_handshake2str (MHD_gnutls_handshake_description_t + handshake); void MHD__gnutls_dump_mpi (const char *prefix, mpi_t a); diff --git a/src/daemon/https/tls/ext_cert_type.c b/src/daemon/https/tls/ext_cert_type.c @@ -183,8 +183,8 @@ MHD_gtls_cert_type_send_params (MHD_gtls_session_t session, opaque * data, for (i = 0; i < len; i++) { data[i + 1] = - MHD__gnutls_cert_type2num (session->internals. - priorities.cert_type.priority[i]); + MHD__gnutls_cert_type2num (session->internals.priorities. + cert_type.priority[i]); } return len + 1; } @@ -203,7 +203,8 @@ MHD_gtls_cert_type_send_params (MHD_gtls_session_t session, opaque * data, } data[0] = - MHD__gnutls_cert_type2num (session->security_parameters.cert_type); + MHD__gnutls_cert_type2num (session->security_parameters. + cert_type); return len; } diff --git a/src/daemon/https/tls/ext_max_record.c b/src/daemon/https/tls/ext_max_record.c @@ -121,8 +121,8 @@ MHD_gtls_max_record_send_params (MHD_gtls_session_t session, opaque * data, } data[0] = - (uint8_t) MHD_gtls_mre_record2num (session->internals. - proposed_record_size); + (uint8_t) MHD_gtls_mre_record2num (session-> + internals.proposed_record_size); return len; } diff --git a/src/daemon/https/tls/ext_oprfi.c b/src/daemon/https/tls/ext_oprfi.c @@ -58,7 +58,8 @@ oprfi_recv_server (MHD_gtls_session_t session, /* Store incoming data. */ session->security_parameters.extensions.oprfi_client_len = len; - session->security_parameters.extensions.oprfi_client = MHD_gnutls_malloc (len); + session->security_parameters.extensions.oprfi_client = + MHD_gnutls_malloc (len); if (!session->security_parameters.extensions.oprfi_client) { MHD_gnutls_assert (); @@ -101,7 +102,8 @@ oprfi_recv_client (MHD_gtls_session_t session, /* Store incoming data. */ session->security_parameters.extensions.oprfi_server_len = len; - session->security_parameters.extensions.oprfi_server = MHD_gnutls_malloc (len); + session->security_parameters.extensions.oprfi_server = + MHD_gnutls_malloc (len); if (!session->security_parameters.extensions.oprfi_server) { MHD_gnutls_assert (); @@ -165,7 +167,8 @@ oprfi_send_server (MHD_gtls_session_t session, opaque * data, session->security_parameters.extensions.oprfi_server_len = session->security_parameters.extensions.oprfi_client_len; session->security_parameters.extensions.oprfi_server = - MHD_gnutls_malloc (session->security_parameters.extensions.oprfi_server_len); + MHD_gnutls_malloc (session->security_parameters.extensions. + oprfi_server_len); if (!session->security_parameters.extensions.oprfi_server) { MHD_gnutls_assert (); @@ -186,8 +189,8 @@ oprfi_send_server (MHD_gtls_session_t session, opaque * data, } DECR_LENGTH_RET (data_size, 2, GNUTLS_E_SHORT_MEMORY_BUFFER); - MHD_gtls_write_uint16 (session->security_parameters. - extensions.oprfi_server_len, p); + MHD_gtls_write_uint16 (session->security_parameters.extensions. + oprfi_server_len, p); p += 2; DECR_LENGTH_RET (data_size, @@ -206,10 +209,10 @@ MHD_gtls_oprfi_send_params (MHD_gtls_session_t session, { #if MHD_DEBUG_TLS if (session->security_parameters.entity == GNUTLS_CLIENT) - return oprfi_send_client (session, data, data_size); + return oprfi_send_client (session, data, data_size); else #endif - return oprfi_send_server (session, data, data_size); + return oprfi_send_server (session, data, data_size); } /** @@ -255,7 +258,8 @@ MHD_gtls_oprfi_enable_client (MHD_gtls_session_t session, **/ void MHD_gtls_oprfi_enable_server (MHD_gtls_session_t session, - MHD_gnutls_oprfi_callback_func cb, void *userdata) + MHD_gnutls_oprfi_callback_func cb, + void *userdata) { session->security_parameters.extensions.oprfi_cb = cb; session->security_parameters.extensions.oprfi_userdata = userdata; diff --git a/src/daemon/https/tls/ext_server_name.c b/src/daemon/https/tls/ext_server_name.c @@ -104,12 +104,12 @@ MHD_gtls_server_name_recv_params (MHD_gtls_session_t session, case 0: /* NAME_DNS */ if (len <= MAX_SERVER_NAME_SIZE) { - memcpy (session->security_parameters.extensions. - server_names[i].name, p, len); - session->security_parameters.extensions. - server_names[i].name_length = len; - session->security_parameters.extensions. - server_names[i].type = GNUTLS_NAME_DNS; + memcpy (session->security_parameters. + extensions.server_names[i].name, p, len); + session->security_parameters.extensions.server_names[i]. + name_length = len; + session->security_parameters.extensions.server_names[i]. + type = GNUTLS_NAME_DNS; break; } } @@ -150,8 +150,8 @@ MHD_gtls_server_name_send_params (MHD_gtls_session_t session, /* count the total size */ len = - session->security_parameters.extensions.server_names[i]. - name_length; + session->security_parameters.extensions. + server_names[i].name_length; /* uint8_t + uint16_t + size */ @@ -170,14 +170,14 @@ MHD_gtls_server_name_send_params (MHD_gtls_session_t session, i < session->security_parameters.extensions.server_names_size; i++) { - switch (session->security_parameters.extensions. - server_names[i].type) + switch (session->security_parameters.extensions.server_names[i]. + type) { case GNUTLS_NAME_DNS: len = - session->security_parameters.extensions. - server_names[i].name_length; + session->security_parameters.extensions.server_names[i]. + name_length; if (len == 0) break; @@ -195,8 +195,8 @@ MHD_gtls_server_name_send_params (MHD_gtls_session_t session, p += 2; memcpy (p, - session->security_parameters.extensions. - server_names[0].name, len); + session->security_parameters.extensions.server_names[0]. + name, len); p += len; break; default: @@ -234,8 +234,8 @@ MHD_gtls_server_name_send_params (MHD_gtls_session_t session, **/ int MHD__gnutls_server_name_get (MHD_gtls_session_t session, void *data, - size_t * data_length, - unsigned int *type, unsigned int indx) + size_t * data_length, + unsigned int *type, unsigned int indx) { char *_data = data; #if MHD_DEBUG_TLS @@ -256,8 +256,8 @@ MHD__gnutls_server_name_get (MHD_gtls_session_t session, void *data, session->security_parameters.extensions.server_names[indx].name_length) { *data_length = - session->security_parameters.extensions.server_names[indx]. - name_length; + session->security_parameters.extensions. + server_names[indx].name_length; memcpy (data, session->security_parameters.extensions.server_names[indx].name, *data_length); @@ -269,8 +269,8 @@ MHD__gnutls_server_name_get (MHD_gtls_session_t session, void *data, else { *data_length = - session->security_parameters.extensions.server_names[indx]. - name_length; + session->security_parameters.extensions. + server_names[indx].name_length; return GNUTLS_E_SHORT_MEMORY_BUFFER; } @@ -296,8 +296,8 @@ MHD__gnutls_server_name_get (MHD_gtls_session_t session, void *data, **/ int MHD__gnutls_server_name_set (MHD_gtls_session_t session, - MHD_gnutls_server_name_type_t type, - const void *name, size_t name_length) + MHD_gnutls_server_name_type_t type, + const void *name, size_t name_length) { int server_names; @@ -318,8 +318,8 @@ MHD__gnutls_server_name_set (MHD_gtls_session_t session, session->security_parameters.extensions.server_names[server_names - 1].type = type; - memcpy (session->security_parameters.extensions. - server_names[server_names - 1].name, name, name_length); + memcpy (session->security_parameters. + extensions.server_names[server_names - 1].name, name, name_length); session->security_parameters.extensions.server_names[server_names - 1].name_length = name_length; diff --git a/src/daemon/https/tls/gnutls_alert.c b/src/daemon/https/tls/gnutls_alert.c @@ -110,8 +110,9 @@ MHD__gnutls_alert_get_name (MHD_gnutls_alert_description_t alert) * **/ int -MHD__gnutls_alert_send (MHD_gtls_session_t session, MHD_gnutls_alert_level_t level, - MHD_gnutls_alert_description_t desc) +MHD__gnutls_alert_send (MHD_gtls_session_t session, + MHD_gnutls_alert_level_t level, + MHD_gnutls_alert_description_t desc) { uint8_t data[2]; int ret; @@ -124,7 +125,7 @@ MHD__gnutls_alert_send (MHD_gtls_session_t session, MHD_gnutls_alert_level_t lev if (name == NULL) name = "(unknown)"; MHD__gnutls_record_log ("REC: Sending Alert[%d|%d] - %s\n", data[0], - data[1], name); + data[1], name); if ((ret = MHD_gtls_send_int (session, GNUTLS_ALERT, -1, data, 2)) >= 0) return 0; diff --git a/src/daemon/https/tls/gnutls_algorithms.c b/src/daemon/https/tls/gnutls_algorithms.c @@ -352,7 +352,8 @@ const int MHD__gnutls_comp_algorithms_size = MAX_COMP_METHODS; /* the compression entry is defined in MHD_gnutls_algorithms.h */ -MHD_gnutls_compression_entry MHD__gnutls_compression_algorithms[MAX_COMP_METHODS] = +MHD_gnutls_compression_entry + MHD__gnutls_compression_algorithms[MAX_COMP_METHODS] = { GNUTLS_COMPRESSION_ENTRY (MHD_GNUTLS_COMP_NULL, 0x00, 0, 0, 0), #ifdef HAVE_LIBZ /* draft-ietf-tls-compression-02 */ @@ -1310,7 +1311,7 @@ MHD_gtls_version_lowest (MHD_gtls_session_t session) } if (min == 0xff) - return MHD_GNUTLS_PROTOCOL_VERSION_UNKNOWN; /* unknown version */ + return MHD_GNUTLS_PROTOCOL_VERSION_UNKNOWN; /* unknown version */ return min; } @@ -1333,7 +1334,7 @@ MHD_gtls_version_max (MHD_gtls_session_t session) } if (max == 0x00) - return MHD_GNUTLS_PROTOCOL_VERSION_UNKNOWN; /* unknown version */ + return MHD_GNUTLS_PROTOCOL_VERSION_UNKNOWN; /* unknown version */ return max; } @@ -1542,11 +1543,11 @@ MHD__gnutls_cipher_suite_is_ok (cipher_suite_st * suite) #define MAX_ELEM_SIZE 4 static inline int MHD__gnutls_partition (MHD_gtls_session_t session, - void *_base, - size_t nmemb, - size_t size, - int (*compar) (MHD_gtls_session_t, - const void *, const void *)) + void *_base, + size_t nmemb, + size_t size, + int (*compar) (MHD_gtls_session_t, + const void *, const void *)) { uint8_t *base = _base; uint8_t tmp[MAX_ELEM_SIZE]; @@ -1590,10 +1591,11 @@ MHD__gnutls_partition (MHD_gtls_session_t session, static void MHD__gnutls_qsort (MHD_gtls_session_t session, - void *_base, - size_t nmemb, - size_t size, - int (*compar) (MHD_gtls_session_t, const void *, const void *)) + void *_base, + size_t nmemb, + size_t size, + int (*compar) (MHD_gtls_session_t, const void *, + const void *)) { unsigned int pivot; char *base = _base; @@ -1613,9 +1615,9 @@ MHD__gnutls_qsort (MHD_gtls_session_t session, pivot = MHD__gnutls_partition (session, _base, nmemb, size, compar); MHD__gnutls_qsort (session, base, pivot < nmemb ? pivot + 1 - : pivot, size, compar); - MHD__gnutls_qsort (session, &base[(pivot + 1) * size], nmemb - pivot - 1, size, - compar); + : pivot, size, compar); + MHD__gnutls_qsort (session, &base[(pivot + 1) * size], nmemb - pivot - 1, + size, compar); } /* a compare function for KX algorithms (using priorities). @@ -1623,7 +1625,7 @@ MHD__gnutls_qsort (MHD_gtls_session_t session, */ static int MHD__gnutls_compare_algo (MHD_gtls_session_t session, - const void *i_A1, const void *i_A2) + const void *i_A1, const void *i_A2) { enum MHD_GNUTLS_KeyExchangeAlgorithm kA1 = MHD_gtls_cipher_suite_get_kx_algo ((const cipher_suite_st *) i_A1); @@ -1662,8 +1664,8 @@ MHD__gnutls_compare_algo (MHD_gtls_session_t session, #ifdef SORT_DEBUG static void MHD__gnutls_bsort (MHD_gtls_session_t session, void *_base, size_t nmemb, - size_t size, int (*compar) (MHD_gtls_session_t, const void *, - const void *)) + size_t size, int (*compar) (MHD_gtls_session_t, + const void *, const void *)) { unsigned int i, j; int full = nmemb * size; @@ -1704,17 +1706,17 @@ MHD_gtls_supported_ciphersuites_sorted (MHD_gtls_session_t session, MHD__gnutls_debug_log ("Unsorted: \n"); for (i = 0; i < count; i++) MHD__gnutls_debug_log ("\t%d: %s\n", i, - MHD_gtls_cipher_suite_get_name ((*ciphers)[i])); + MHD_gtls_cipher_suite_get_name ((*ciphers)[i])); #endif MHD__gnutls_qsort (session, *ciphers, count, sizeof (cipher_suite_st), - MHD__gnutls_compare_algo); + MHD__gnutls_compare_algo); #ifdef SORT_DEBUG MHD__gnutls_debug_log ("Sorted: \n"); for (i = 0; i < count; i++) MHD__gnutls_debug_log ("\t%d: %s\n", i, - MHD_gtls_cipher_suite_get_name ((*ciphers)[i])); + MHD_gtls_cipher_suite_get_name ((*ciphers)[i])); #endif return count; @@ -1832,15 +1834,16 @@ MHD_gtls_supported_compression_methods (MHD_gtls_session_t session, { unsigned int i, j; - *comp = MHD_gnutls_malloc (sizeof (uint8_t) * SUPPORTED_COMPRESSION_METHODS); + *comp = + MHD_gnutls_malloc (sizeof (uint8_t) * SUPPORTED_COMPRESSION_METHODS); if (*comp == NULL) return GNUTLS_E_MEMORY_ERROR; for (i = j = 0; i < SUPPORTED_COMPRESSION_METHODS; i++) { int tmp = - MHD_gtls_compression_get_num (session->internals.priorities. - compression.priority[i]); + MHD_gtls_compression_get_num (session->internals. + priorities.compression.priority[i]); /* remove private compression algorithms, if requested. */ diff --git a/src/daemon/https/tls/gnutls_algorithms.h b/src/daemon/https/tls/gnutls_algorithms.h @@ -93,7 +93,8 @@ int MHD_gtls_kx_is_ok (enum MHD_GNUTLS_KeyExchangeAlgorithm algorithm); 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_from_int (int num); +enum MHD_GNUTLS_CompressionMethod MHD_gtls_compression_get_id_from_int (int + num); int MHD_gtls_compression_get_mem_level (enum MHD_GNUTLS_CompressionMethod algorithm); int MHD_gtls_compression_get_comp_level (enum MHD_GNUTLS_CompressionMethod @@ -140,13 +141,14 @@ struct MHD_gtls_compression_entry typedef struct MHD_gtls_compression_entry MHD_gnutls_compression_entry; /* Functions for sign algorithms. */ -MHD_gnutls_sign_algorithm_t MHD_gtls_x509_oid2sign_algorithm (const char *oid); +MHD_gnutls_sign_algorithm_t MHD_gtls_x509_oid2sign_algorithm (const char + *oid); MHD_gnutls_sign_algorithm_t MHD_gtls_x509_pk_to_sign (enum - MHD_GNUTLS_PublicKeyAlgorithm - pk, - enum - MHD_GNUTLS_HashAlgorithm - mac); + 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); diff --git a/src/daemon/https/tls/gnutls_anon_cred.c b/src/daemon/https/tls/gnutls_anon_cred.c @@ -44,7 +44,7 @@ static const int anon_dummy; **/ void MHD__gnutls_anon_free_server_credentials (MHD_gtls_anon_server_credentials_t - sc) + sc) { MHD_gnutls_free (sc); @@ -80,7 +80,7 @@ int **/ void MHD__gnutls_anon_free_client_credentials (MHD_gtls_anon_client_credentials_t - sc) + sc) { } @@ -116,7 +116,7 @@ int **/ void MHD__gnutls_anon_set_server_dh_params (MHD_gtls_anon_server_credentials_t res, - MHD_gtls_dh_params_t dh_params) + MHD_gtls_dh_params_t dh_params) { res->dh_params = dh_params; } @@ -131,9 +131,8 @@ MHD__gnutls_anon_set_server_dh_params (MHD_gtls_anon_server_credentials_t res, * callback should return zero on success. **/ void -MHD__gnutls_anon_set_server_params_function (MHD_gtls_anon_server_credentials_t - res, - MHD_gnutls_params_function * func) +MHD__gnutls_anon_set_server_params_function + (MHD_gtls_anon_server_credentials_t res, MHD_gnutls_params_function * func) { res->params_func = func; } 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, - enum MHD_GNUTLS_CredentialsType type, void *cred) + enum MHD_GNUTLS_CredentialsType type, void *cred) { auth_cred_st *ccred = NULL, *pcred = NULL; int exists = 0; @@ -170,8 +170,9 @@ MHD_gtls_auth_get_type (MHD_gtls_session_t session) return MHD_gtls_map_kx_get_cred (MHD_gtls_cipher_suite_get_kx_algo - (&session->security_parameters. - current_cipher_suite), server); + (&session-> + security_parameters.current_cipher_suite), + server); } /** @@ -188,8 +189,8 @@ MHD_gtls_auth_server_get_type (MHD_gtls_session_t session) { return MHD_gtls_map_kx_get_cred (MHD_gtls_cipher_suite_get_kx_algo - (&session->security_parameters. - current_cipher_suite), 1); + (&session-> + security_parameters.current_cipher_suite), 1); } /** @@ -206,8 +207,8 @@ MHD_gtls_auth_client_get_type (MHD_gtls_session_t session) { return MHD_gtls_map_kx_get_cred (MHD_gtls_cipher_suite_get_kx_algo - (&session->security_parameters. - current_cipher_suite), 0); + (&session-> + security_parameters.current_cipher_suite), 0); } diff --git a/src/daemon/https/tls/gnutls_buffers.c b/src/daemon/https/tls/gnutls_buffers.c @@ -137,19 +137,19 @@ MHD_gnutls_record_buffer_put (content_type_t type, case GNUTLS_APPLICATION_DATA: buf = &session->internals.application_data_buffer; MHD__gnutls_buffers_log ("BUF[REC]: Inserted %d bytes of Data(%d)\n", - length, type); + length, type); break; case GNUTLS_HANDSHAKE: buf = &session->internals.handshake_data_buffer; MHD__gnutls_buffers_log ("BUF[HSK]: Inserted %d bytes of Data(%d)\n", - length, type); + length, type); break; case GNUTLS_INNER_APPLICATION: buf = &session->internals.ia_data_buffer; - MHD__gnutls_buffers_log ("BUF[IA]: Inserted %d bytes of Data(%d)\n", length, - type); + MHD__gnutls_buffers_log ("BUF[IA]: Inserted %d bytes of Data(%d)\n", + length, type); break; default: @@ -223,7 +223,7 @@ MHD_gtls_record_buffer_get (content_type_t type, MHD_gtls_session_t session, } MHD__gnutls_buffers_log ("BUFFER[REC][AD]: Read %d bytes of Data(%d)\n", - length, type); + length, type); session->internals.application_data_buffer.length -= length; memcpy (data, session->internals.application_data_buffer.data, length); @@ -246,7 +246,7 @@ MHD_gtls_record_buffer_get (content_type_t type, MHD_gtls_session_t session, } MHD__gnutls_buffers_log ("BUF[REC][HD]: Read %d bytes of Data(%d)\n", - length, type); + length, type); session->internals.handshake_data_buffer.length -= length; memcpy (data, session->internals.handshake_data_buffer.data, length); @@ -263,7 +263,7 @@ MHD_gtls_record_buffer_get (content_type_t type, MHD_gtls_session_t session, length = session->internals.ia_data_buffer.length; MHD__gnutls_buffers_log ("BUF[REC][IA]: Read %d bytes of Data(%d)\n", - length, type); + length, type); session->internals.ia_data_buffer.length -= length; memcpy (data, session->internals.ia_data_buffer.data, length); @@ -290,7 +290,7 @@ MHD_gtls_record_buffer_get (content_type_t type, MHD_gtls_session_t session, */ static ssize_t MHD__gnutls_read (MHD_gtls_session_t session, void *iptr, - size_t sizeOfPtr, int flags) + size_t sizeOfPtr, int flags) { size_t left; ssize_t i = 0; @@ -333,16 +333,17 @@ MHD__gnutls_read (MHD_gtls_session_t session, void *iptr, } else i = session->internals.MHD__gnutls_pull_func (fd, - &ptr[sizeOfPtr - left], - left); + &ptr[sizeOfPtr - left], + left); if (i < 0) { int err = session->internals.errnum ? session->internals.errnum : errno; - MHD__gnutls_read_log ("READ: %d returned from %d, errno=%d gerrno=%d\n", - i, fd, errno, session->internals.errnum); + MHD__gnutls_read_log + ("READ: %d returned from %d, errno=%d gerrno=%d\n", i, fd, errno, + session->internals.errnum); if (err == EAGAIN || err == EINTR) { @@ -350,7 +351,7 @@ MHD__gnutls_read (MHD_gtls_session_t session, void *iptr, { MHD__gnutls_read_log ("READ: returning %d bytes from %d\n", - sizeOfPtr - left, fd); + sizeOfPtr - left, fd); goto finish; } @@ -386,8 +387,8 @@ finish: char line[128]; char tmp[16]; - MHD__gnutls_read_log ("READ: read %d bytes from %d\n", (sizeOfPtr - left), - fd); + MHD__gnutls_read_log ("READ: read %d bytes from %d\n", + (sizeOfPtr - left), fd); for (x = 0; x < ((sizeOfPtr - left) / 16) + 1; x++) { @@ -486,7 +487,7 @@ MHD_gtls_io_read_buffered (MHD_gtls_session_t session, opaque ** iptr, if (sizeOfPtr > MAX_RECV_SIZE || sizeOfPtr == 0) { - MHD_gnutls_assert (); /* internal error */ + MHD_gnutls_assert (); /* internal error */ return GNUTLS_E_INVALID_REQUEST; } @@ -536,7 +537,7 @@ MHD_gtls_io_read_buffered (MHD_gtls_session_t session, opaque ** iptr, if ((session->internals.record_recv_buffer.length + recvdata) > MAX_RECV_SIZE) { - MHD_gnutls_assert (); /* internal error */ + MHD_gnutls_assert (); /* internal error */ return GNUTLS_E_INVALID_REQUEST; } @@ -559,7 +560,8 @@ MHD_gtls_io_read_buffered (MHD_gtls_session_t session, opaque ** iptr, /* READ DATA - but leave RCVLOWAT bytes in the kernel buffer. */ if (recvdata - recvlowat > 0) { - ret = MHD__gnutls_read (session, &buf[buf_pos], recvdata - recvlowat, 0); + ret = + MHD__gnutls_read (session, &buf[buf_pos], recvdata - recvlowat, 0); /* return immediately if we got an interrupt or eagain * error. @@ -574,8 +576,9 @@ MHD_gtls_io_read_buffered (MHD_gtls_session_t session, opaque ** iptr, */ if (ret > 0) { - MHD__gnutls_read_log ("RB: Have %d bytes into buffer. Adding %d bytes.\n", - session->internals.record_recv_buffer.length, ret); + MHD__gnutls_read_log + ("RB: Have %d bytes into buffer. Adding %d bytes.\n", + session->internals.record_recv_buffer.length, ret); MHD__gnutls_read_log ("RB: Requested %d bytes\n", sizeOfPtr); session->internals.record_recv_buffer.length += ret; } @@ -598,7 +601,8 @@ MHD_gtls_io_read_buffered (MHD_gtls_session_t session, opaque ** iptr, if (ret2 > 0) { - MHD__gnutls_read_log ("RB-PEEK: Read %d bytes in PEEK MODE.\n", ret2); + MHD__gnutls_read_log ("RB-PEEK: Read %d bytes in PEEK MODE.\n", + ret2); MHD__gnutls_read_log ("RB-PEEK: Have %d bytes into buffer. Adding %d bytes.\nRB: Requested %d bytes\n", session->internals.record_recv_buffer.length, ret2, sizeOfPtr); @@ -652,7 +656,7 @@ MHD_gtls_io_read_buffered (MHD_gtls_session_t session, opaque ** iptr, inline static int MHD__gnutls_buffer_insert (MHD_gtls_buffer * buffer, - const opaque * _data, size_t data_size) + const opaque * _data, size_t data_size) { if ((MEMSUB (_data, buffer->data) >= 0) @@ -691,7 +695,7 @@ MHD__gnutls_buffer_insert (MHD_gtls_buffer * buffer, inline static int MHD__gnutls_buffer_get (MHD_gtls_buffer * buffer, - const opaque ** ptr, size_t * ptr_size) + const opaque ** ptr, size_t * ptr_size) { *ptr_size = buffer->length; *ptr = buffer->data; @@ -742,7 +746,8 @@ MHD_gtls_io_write_buffered (MHD_gtls_session_t session, if (iptr == NULL) { /* checking is handled above */ - ret = MHD__gnutls_buffer_get (&session->internals.record_send_buffer, &ptr, + ret = + MHD__gnutls_buffer_get (&session->internals.record_send_buffer, &ptr, &n); if (ret < 0) { @@ -750,8 +755,8 @@ MHD_gtls_io_write_buffered (MHD_gtls_session_t session, return ret; } - MHD__gnutls_write_log ("WRITE: Restoring old write. (%d bytes to send)\n", - n); + MHD__gnutls_write_log + ("WRITE: Restoring old write. (%d bytes to send)\n", n); } MHD__gnutls_write_log ("WRITE: Will write %d bytes to %d.\n", n, fd); @@ -789,7 +794,8 @@ MHD_gtls_io_write_buffered (MHD_gtls_session_t session, #endif } else - i = session->internals.MHD__gnutls_push_func (fd, &ptr[n - left], left); + i = + session->internals.MHD__gnutls_push_func (fd, &ptr[n - left], left); if (i == -1) { @@ -801,8 +807,9 @@ MHD_gtls_io_write_buffered (MHD_gtls_session_t session, session->internals.record_send_buffer_prev_size += n - left; retval = - MHD__gnutls_buffer_insert (&session->internals.record_send_buffer, - &ptr[n - left], left); + MHD__gnutls_buffer_insert (&session->internals. + record_send_buffer, &ptr[n - left], + left); if (retval < 0) { MHD_gnutls_assert (); @@ -881,7 +888,7 @@ MHD_gtls_io_write_flush (MHD_gtls_session_t session) ret = MHD_gtls_io_write_buffered (session, NULL, 0); MHD__gnutls_write_log ("WRITE FLUSH: %d [buffer: %d]\n", ret, - session->internals.record_send_buffer.length); + session->internals.record_send_buffer.length); return ret; } @@ -935,7 +942,7 @@ MHD_gtls_handshake_io_send_int (MHD_gtls_session_t session, */ MHD_gnutls_assert (); ret = MHD__gnutls_buffer_get (&session->internals.handshake_send_buffer, - &ptr, &n); + &ptr, &n); if (ret < 0) { MHD_gnutls_assert (); @@ -957,7 +964,7 @@ MHD_gtls_handshake_io_send_int (MHD_gtls_session_t session, size_t sum = 0, x, j; MHD__gnutls_write_log ("HWRITE: will write %d bytes to %d.\n", n, - MHD_gnutls_transport_get_ptr (session)); + MHD_gnutls_transport_get_ptr (session)); for (x = 0; x < ((n) / 16) + 1; x++) { if (sum > n) @@ -968,7 +975,8 @@ MHD_gtls_handshake_io_send_int (MHD_gtls_session_t session, { if (sum < n) { - MHD__gnutls_write_log ("%.2x ", ((unsigned char *) ptr)[sum++]); + MHD__gnutls_write_log ("%.2x ", + ((unsigned char *) ptr)[sum++]); } else break; @@ -1009,9 +1017,9 @@ MHD_gtls_handshake_io_send_int (MHD_gtls_session_t session, MHD_gnutls_assert (); retval = - MHD__gnutls_buffer_insert (&session->internals. - handshake_send_buffer, &ptr[n - left], - left); + MHD__gnutls_buffer_insert (&session-> + internals.handshake_send_buffer, + &ptr[n - left], left); if (retval < 0) { MHD_gnutls_assert (); @@ -1112,8 +1120,9 @@ MHD_gtls_handshake_io_recv_int (MHD_gtls_session_t session, session->internals.handshake_recv_buffer.data = - MHD_gtls_realloc_fast (session->internals. - handshake_recv_buffer.data, dsize); + MHD_gtls_realloc_fast (session-> + internals.handshake_recv_buffer.data, + dsize); if (session->internals.handshake_recv_buffer.data == NULL) { MHD_gnutls_assert (); @@ -1164,13 +1173,9 @@ MHD_gtls_handshake_buffer_put (MHD_gtls_session_t session, opaque * data, if ((session->internals.max_handshake_data_buffer_size > 0) && ((length + - session-> - internals. - handshake_hash_buffer. - length) > - session-> - internals. - max_handshake_data_buffer_size)) + session->internals.handshake_hash_buffer.length) + > + session->internals.max_handshake_data_buffer_size)) { MHD_gnutls_assert (); return GNUTLS_E_MEMORY_ERROR; @@ -1224,7 +1229,7 @@ MHD_gtls_handshake_buffer_get_ptr (MHD_gtls_session_t session, *length = session->internals.handshake_hash_buffer.length; MHD__gnutls_buffers_log ("BUF[HSK]: Peeked %d bytes of Data\n", - session->internals.handshake_hash_buffer.length); + session->internals.handshake_hash_buffer.length); if (data_ptr != NULL) *data_ptr = session->internals.handshake_hash_buffer.data; diff --git a/src/daemon/https/tls/gnutls_cert.c b/src/daemon/https/tls/gnutls_cert.c @@ -210,7 +210,7 @@ MHD__gnutls_certificate_free_credentials (MHD_gtls_cert_credentials_t sc) **/ int MHD__gnutls_certificate_allocate_credentials (MHD_gtls_cert_credentials_t * - res) + res) { *res = MHD_gnutls_calloc (1, sizeof (MHD_gtls_cert_credentials_st)); @@ -271,7 +271,8 @@ MHD_gtls_selected_cert_supported_kx (MHD_gtls_session_t session, return GNUTLS_E_INVALID_REQUEST; } - *alg = MHD_gnutls_calloc (1, sizeof (enum MHD_GNUTLS_KeyExchangeAlgorithm) * i); + *alg = + MHD_gnutls_calloc (1, sizeof (enum MHD_GNUTLS_KeyExchangeAlgorithm) * i); if (*alg == NULL) return GNUTLS_E_MEMORY_ERROR; @@ -550,8 +551,9 @@ MHD_gtls_certificate_expiration_time_peers (MHD_gtls_session_t session) { case MHD_GNUTLS_CRT_X509: return - MHD__gnutls_x509_get_raw_crt_expiration_time (&info->raw_certificate_list - [0]); + MHD__gnutls_x509_get_raw_crt_expiration_time (&info-> + raw_certificate_list + [0]); default: return (time_t) - 1; } @@ -589,8 +591,9 @@ MHD_gtls_certificate_activation_time_peers (MHD_gtls_session_t session) { case MHD_GNUTLS_CRT_X509: return - MHD__gnutls_x509_get_raw_crt_activation_time (&info->raw_certificate_list - [0]); + MHD__gnutls_x509_get_raw_crt_activation_time (&info-> + raw_certificate_list + [0]); default: return (time_t) - 1; } @@ -695,7 +698,8 @@ MHD_gtls_x509_crt_to_gcert (MHD_gnutls_cert * gcert, } ret = - MHD_gnutls_x509_crt_export (cert, GNUTLS_X509_FMT_DER, der, &der_size); + MHD_gnutls_x509_crt_export (cert, GNUTLS_X509_FMT_DER, der, + &der_size); if (ret < 0 && ret != GNUTLS_E_SHORT_MEMORY_BUFFER) { MHD_gnutls_assert (); @@ -714,7 +718,7 @@ MHD_gtls_x509_crt_to_gcert (MHD_gnutls_cert * gcert, ret = MHD_gnutls_x509_crt_export (cert, GNUTLS_X509_FMT_DER, der, - &der_size); + &der_size); if (ret < 0) { MHD_gnutls_assert (); @@ -736,13 +740,15 @@ MHD_gtls_x509_crt_to_gcert (MHD_gnutls_cert * gcert, MHD_gnutls_x509_crt_get_key_usage (cert, &gcert->key_usage, NULL); gcert->version = MHD_gnutls_x509_crt_get_version (cert); } - gcert->subject_pk_algorithm = MHD_gnutls_x509_crt_get_pk_algorithm (cert, NULL); + gcert->subject_pk_algorithm = + MHD_gnutls_x509_crt_get_pk_algorithm (cert, NULL); if (flags & CERT_ONLY_PUBKEY || flags == 0) { gcert->params_size = MAX_PUBLIC_PARAMS_SIZE; ret = - MHD__gnutls_x509_crt_get_mpis (cert, gcert->params, &gcert->params_size); + MHD__gnutls_x509_crt_get_mpis (cert, gcert->params, + &gcert->params_size); if (ret < 0) { MHD_gnutls_assert (); diff --git a/src/daemon/https/tls/gnutls_cert.h b/src/daemon/https/tls/gnutls_cert.h @@ -110,7 +110,8 @@ typedef enum ConvFlags int MHD_gtls_x509_raw_cert_to_gcert (MHD_gnutls_cert * gcert, const MHD_gnutls_datum_t * derCert, int flags); -int MHD_gtls_x509_crt_to_gcert (MHD_gnutls_cert * gcert, MHD_gnutls_x509_crt_t cert, +int MHD_gtls_x509_crt_to_gcert (MHD_gnutls_cert * gcert, + MHD_gnutls_x509_crt_t cert, unsigned int flags); void MHD_gtls_gkey_deinit (MHD_gnutls_privkey * key); diff --git a/src/daemon/https/tls/gnutls_cipher.c b/src/daemon/https/tls/gnutls_cipher.c @@ -244,7 +244,7 @@ calc_enc_length (MHD_gtls_session_t session, int data_size, break; case CIPHER_BLOCK: - if (MHD_gc_nonce ((char*) &rnd, 1) != GC_OK) + if (MHD_gc_nonce ((char *) &rnd, 1) != GC_OK) { MHD_gnutls_assert (); return GNUTLS_E_RANDOM_FAILED; @@ -302,15 +302,15 @@ MHD_gtls_compressed2ciphertext (MHD_gtls_session_t session, uint8_t type = _type; uint8_t major, minor; int hash_size = - MHD_gnutls_hash_get_algo_len (session->security_parameters. - write_mac_algorithm); + MHD_gnutls_hash_get_algo_len (session-> + security_parameters.write_mac_algorithm); enum MHD_GNUTLS_Protocol ver; int blocksize = - MHD_gtls_cipher_get_block_size (session->security_parameters. - write_bulk_cipher_algorithm); + MHD_gtls_cipher_get_block_size (session-> + security_parameters.write_bulk_cipher_algorithm); cipher_type_t block_algo = - MHD_gtls_cipher_is_block (session->security_parameters. - write_bulk_cipher_algorithm); + MHD_gtls_cipher_is_block (session-> + security_parameters.write_bulk_cipher_algorithm); opaque *data_ptr; @@ -337,8 +337,9 @@ MHD_gtls_compressed2ciphertext (MHD_gtls_session_t session, if (td != GNUTLS_MAC_FAILED) { /* actually when the algorithm in not the NULL one */ MHD_gnutls_hash (td, - UINT64DATA (session->connection_state. - write_sequence_number), 8); + UINT64DATA (session-> + connection_state.write_sequence_number), + 8); MHD_gnutls_hash (td, &type, 1); if (ver >= MHD_GNUTLS_PROTOCOL_TLS1_0) @@ -377,7 +378,7 @@ MHD_gtls_compressed2ciphertext (MHD_gtls_session_t session, { /* copy the random IV. */ - if (MHD_gc_nonce ((char*) data_ptr, blocksize) != GC_OK) + if (MHD_gc_nonce ((char *) data_ptr, blocksize) != GC_OK) { MHD_gnutls_assert (); return GNUTLS_E_RANDOM_FAILED; @@ -432,16 +433,16 @@ MHD_gtls_ciphertext2compressed (MHD_gtls_session_t session, uint8_t major, minor; enum MHD_GNUTLS_Protocol ver; int hash_size = - MHD_gnutls_hash_get_algo_len (session->security_parameters. - read_mac_algorithm); + MHD_gnutls_hash_get_algo_len (session-> + security_parameters.read_mac_algorithm); ver = MHD__gnutls_protocol_get_version (session); minor = MHD_gtls_version_get_minor (ver); major = MHD_gtls_version_get_major (ver); blocksize = - MHD_gtls_cipher_get_block_size (session->security_parameters. - read_bulk_cipher_algorithm); + MHD_gtls_cipher_get_block_size (session-> + security_parameters.read_bulk_cipher_algorithm); /* initialize MAC */ @@ -465,9 +466,9 @@ MHD_gtls_ciphertext2compressed (MHD_gtls_session_t session, { case CIPHER_STREAM: if ((ret = - MHD_gtls_cipher_decrypt (session->connection_state. - read_cipher_state, ciphertext.data, - ciphertext.size)) < 0) + MHD_gtls_cipher_decrypt (session-> + connection_state.read_cipher_state, + ciphertext.data, ciphertext.size)) < 0) { MHD_gnutls_assert (); return ret; @@ -484,9 +485,9 @@ MHD_gtls_ciphertext2compressed (MHD_gtls_session_t session, } if ((ret = - MHD_gtls_cipher_decrypt (session->connection_state. - read_cipher_state, ciphertext.data, - ciphertext.size)) < 0) + MHD_gtls_cipher_decrypt (session-> + connection_state.read_cipher_state, + ciphertext.data, ciphertext.size)) < 0) { MHD_gnutls_assert (); return ret; @@ -544,8 +545,8 @@ MHD_gtls_ciphertext2compressed (MHD_gtls_session_t session, if (td != GNUTLS_MAC_FAILED) { MHD_gnutls_hash (td, - UINT64DATA (session->connection_state. - read_sequence_number), 8); + UINT64DATA (session-> + connection_state.read_sequence_number), 8); MHD_gnutls_hash (td, &type, 1); if (ver >= MHD_GNUTLS_PROTOCOL_TLS1_0) diff --git a/src/daemon/https/tls/gnutls_cipher.h b/src/daemon/https/tls/gnutls_cipher.h @@ -37,4 +37,5 @@ int MHD_gtls_compressed2ciphertext (MHD_gtls_session_t session, content_type_t _type, int random_pad); int MHD_gtls_ciphertext2compressed (MHD_gtls_session_t session, opaque * compress_data, int compress_size, - MHD_gnutls_datum_t ciphertext, uint8_t type); + MHD_gnutls_datum_t ciphertext, + uint8_t type); diff --git a/src/daemon/https/tls/gnutls_cipher_int.c b/src/daemon/https/tls/gnutls_cipher_int.c @@ -29,7 +29,8 @@ cipher_hd_t MHD_gtls_cipher_init (enum MHD_GNUTLS_CipherAlgorithm cipher, - const MHD_gnutls_datum_t * key, const MHD_gnutls_datum_t * iv) + const MHD_gnutls_datum_t * key, + const MHD_gnutls_datum_t * iv) { cipher_hd_t ret = NULL; int err = GC_INVALID_CIPHER; /* doesn't matter */ @@ -80,9 +81,9 @@ MHD_gtls_cipher_init (enum MHD_GNUTLS_CipherAlgorithm cipher, if (err == 0) { - MHD_gc_cipher_setkey (ret, key->size, (const char*) key->data); + MHD_gc_cipher_setkey (ret, key->size, (const char *) key->data); if (iv->data != NULL && iv->size > 0) - MHD_gc_cipher_setiv (ret, iv->size, (const char*) iv->data); + MHD_gc_cipher_setiv (ret, iv->size, (const char *) iv->data); } else if (cipher != MHD_GNUTLS_CIPHER_NULL) { @@ -114,7 +115,8 @@ MHD_gtls_cipher_decrypt (cipher_hd_t handle, void *ciphertext, { if (handle != GNUTLS_CIPHER_FAILED) { - if (MHD_gc_cipher_decrypt_inline (handle, ciphertextlen, ciphertext) != 0) + if (MHD_gc_cipher_decrypt_inline (handle, ciphertextlen, ciphertext) != + 0) { MHD_gnutls_assert (); return GNUTLS_E_INTERNAL_ERROR; diff --git a/src/daemon/https/tls/gnutls_compress.c b/src/daemon/https/tls/gnutls_compress.c @@ -35,8 +35,8 @@ */ int MHD__gnutls_m_plaintext2compressed (MHD_gtls_session_t session, - MHD_gnutls_datum_t * compressed, - const MHD_gnutls_datum_t * plaintext) + MHD_gnutls_datum_t * compressed, + const MHD_gnutls_datum_t * plaintext) { int size; opaque *data; @@ -58,8 +58,8 @@ MHD__gnutls_m_plaintext2compressed (MHD_gtls_session_t session, int MHD__gnutls_m_compressed2plaintext (MHD_gtls_session_t session, - MHD_gnutls_datum_t * plain, - const MHD_gnutls_datum_t * compressed) + MHD_gnutls_datum_t * plain, + const MHD_gnutls_datum_t * compressed) { int size; opaque *data; diff --git a/src/daemon/https/tls/gnutls_compress.h b/src/daemon/https/tls/gnutls_compress.h @@ -23,8 +23,9 @@ */ int MHD__gnutls_m_plaintext2compressed (MHD_gtls_session_t session, - MHD_gnutls_datum_t * compressed, - const MHD_gnutls_datum_t * plaintext); + MHD_gnutls_datum_t * compressed, + const MHD_gnutls_datum_t * plaintext); int MHD__gnutls_m_compressed2plaintext (MHD_gtls_session_t session, - MHD_gnutls_datum_t * plain, - const MHD_gnutls_datum_t * compressed); + MHD_gnutls_datum_t * plain, + const MHD_gnutls_datum_t * + compressed); diff --git a/src/daemon/https/tls/gnutls_compress_int.c b/src/daemon/https/tls/gnutls_compress_int.c @@ -52,7 +52,7 @@ MHD_gtls_comp_init (enum MHD_GNUTLS_CompressionMethod method, int d) { int window_bits, mem_level; int comp_level; - int err; + int err; z_stream *zhandle; window_bits = MHD_gtls_compression_get_wbits (method); @@ -74,10 +74,10 @@ MHD_gtls_comp_init (enum MHD_GNUTLS_CompressionMethod method, int d) if (d) err = inflateInit2 (zhandle, window_bits); - else - err = deflateInit2 (zhandle, - comp_level, Z_DEFLATED, - window_bits, mem_level, Z_DEFAULT_STRATEGY); + else + err = deflateInit2 (zhandle, + comp_level, Z_DEFLATED, + window_bits, mem_level, Z_DEFAULT_STRATEGY); if (err != Z_OK) { MHD_gnutls_assert (); @@ -111,7 +111,7 @@ MHD_gtls_comp_deinit (comp_hd_t handle, int d) switch (handle->algo) { #ifdef HAVE_LIBZ - int err; + int err; case MHD_GNUTLS_COMP_DEFLATE: if (d) err = inflateEnd (handle->handle); @@ -154,7 +154,7 @@ MHD_gtls_compress (comp_hd_t handle, const opaque * plain, { uLongf size; z_stream *zhandle; - int err; + int err; size = (plain_size + plain_size) + 10; *compressed = MHD_gnutls_malloc (size); @@ -192,7 +192,8 @@ MHD_gtls_compress (comp_hd_t handle, const opaque * plain, #ifdef COMPRESSION_DEBUG MHD__gnutls_debug_log ("Compression ratio: %f\n", - (float) ((float) compressed_size / (float) plain_size)); + (float) ((float) compressed_size / + (float) plain_size)); #endif if ((size_t) compressed_size > max_comp_size) @@ -234,10 +235,10 @@ MHD_gtls_decompress (comp_hd_t handle, opaque * compressed, #ifdef HAVE_LIBZ case MHD_GNUTLS_COMP_DEFLATE: { - int err; + int err; uLongf out_size; z_stream *zhandle; - unsigned int cur_pos; + unsigned int cur_pos; *plain = NULL; out_size = compressed_size + compressed_size; diff --git a/src/daemon/https/tls/gnutls_constate.c b/src/daemon/https/tls/gnutls_constate.c @@ -57,7 +57,7 @@ static const int servwrite_length = sizeof (servwrite) - 1; */ int MHD__gnutls_set_keys (MHD_gtls_session_t session, int hash_size, int IV_size, - int key_size, int export_flag) + int key_size, int export_flag) { /* FIXME: This function is too long @@ -107,8 +107,9 @@ MHD__gnutls_set_keys (MHD_gtls_session_t session, int hash_size, int IV_size, else { /* TLS 1.0 */ ret = - MHD_gtls_PRF (session, (const unsigned char*) session->security_parameters.master_secret, - TLS_MASTER_SIZE, keyexp, keyexp_length, + MHD_gtls_PRF (session, + (const unsigned char *) session->security_parameters. + master_secret, TLS_MASTER_SIZE, keyexp, keyexp_length, rnd, 2 * TLS_RANDOM_SIZE, block_size, key_block); } @@ -120,8 +121,8 @@ MHD__gnutls_set_keys (MHD_gtls_session_t session, int hash_size, int IV_size, } MHD__gnutls_hard_log ("INT: KEY BLOCK[%d]: %s\n", block_size, - MHD_gtls_bin2hex (key_block, block_size, buf, - sizeof (buf))); + MHD_gtls_bin2hex (key_block, block_size, buf, + sizeof (buf))); pos = 0; if (hash_size > 0) @@ -187,7 +188,8 @@ MHD__gnutls_set_keys (MHD_gtls_session_t session, int hash_size, int IV_size, /* generate the final keys */ - if (session->security_parameters.version == MHD_GNUTLS_PROTOCOL_SSL3) + if (session->security_parameters.version == + MHD_GNUTLS_PROTOCOL_SSL3) { /* SSL 3 */ ret = MHD_gnutls_ssl3_hash_md5 (&key_block[pos], @@ -219,7 +221,8 @@ MHD__gnutls_set_keys (MHD_gtls_session_t session, int hash_size, int IV_size, client_write_key_size = EXPORT_FINAL_KEY_SIZE; pos += key_size; - if (session->security_parameters.version == MHD_GNUTLS_PROTOCOL_SSL3) + if (session->security_parameters.version == + MHD_GNUTLS_PROTOCOL_SSL3) { /* SSL 3 */ ret = MHD_gnutls_ssl3_hash_md5 (&key_block[pos], key_size, @@ -259,10 +262,10 @@ MHD__gnutls_set_keys (MHD_gtls_session_t session, int hash_size, int IV_size, return GNUTLS_E_MEMORY_ERROR; } MHD__gnutls_hard_log ("INT: CLIENT WRITE KEY [%d]: %s\n", - client_write_key_size, - MHD_gtls_bin2hex (client_write_key, - client_write_key_size, buf, - sizeof (buf))); + client_write_key_size, + MHD_gtls_bin2hex (client_write_key, + client_write_key_size, buf, + sizeof (buf))); if (MHD__gnutls_sset_datum (&session->cipher_specs.server_write_key, @@ -275,10 +278,10 @@ MHD__gnutls_set_keys (MHD_gtls_session_t session, int hash_size, int IV_size, } MHD__gnutls_hard_log ("INT: SERVER WRITE KEY [%d]: %s\n", - server_write_key_size, - MHD_gtls_bin2hex (server_write_key, - server_write_key_size, buf, - sizeof (buf))); + server_write_key_size, + MHD_gtls_bin2hex (server_write_key, + server_write_key_size, buf, + sizeof (buf))); if (free_keys != 0) { @@ -342,7 +345,7 @@ MHD__gnutls_set_keys (MHD_gtls_session_t session, int hash_size, int IV_size, } else { /* TLS 1.0 */ - ret = MHD_gtls_PRF (session, (const unsigned char*) "", 0, + ret = MHD_gtls_PRF (session, (const unsigned char *) "", 0, ivblock, ivblock_length, rrnd, 2 * TLS_RANDOM_SIZE, IV_size * 2, iv_block); } @@ -400,7 +403,7 @@ MHD__gnutls_set_read_keys (MHD_gtls_session_t session) export_flag = MHD_gtls_cipher_get_export_flag (algo); return MHD__gnutls_set_keys (session, hash_size, IV_size, key_size, - export_flag); + export_flag); } int @@ -421,7 +424,7 @@ MHD__gnutls_set_write_keys (MHD_gtls_session_t session) export_flag = MHD_gtls_cipher_get_export_flag (algo); return MHD__gnutls_set_keys (session, hash_size, IV_size, key_size, - export_flag); + export_flag); } #define CPY_COMMON dst->entity = src->entity; \ @@ -442,7 +445,8 @@ MHD__gnutls_set_write_keys (MHD_gtls_session_t session) static void MHD__gnutls_cpy_read_security_parameters (MHD_gtls_security_param_st * - dst, MHD_gtls_security_param_st * src) + dst, + MHD_gtls_security_param_st * src) { CPY_COMMON; @@ -453,7 +457,8 @@ MHD__gnutls_cpy_read_security_parameters (MHD_gtls_security_param_st * static void MHD__gnutls_cpy_write_security_parameters (MHD_gtls_security_param_st * - dst, MHD_gtls_security_param_st * src) + dst, + MHD_gtls_security_param_st * src) { CPY_COMMON; @@ -504,35 +509,35 @@ MHD_gtls_read_connection_state_init (MHD_gtls_session_t session) { rc = MHD_gtls_set_read_cipher (session, MHD_gtls_cipher_suite_get_cipher_algo - (&session->security_parameters. - current_cipher_suite)); + (&session-> + security_parameters.current_cipher_suite)); if (rc < 0) return rc; rc = MHD_gtls_set_read_mac (session, MHD_gtls_cipher_suite_get_mac_algo - (&session->security_parameters. - current_cipher_suite)); + (&session-> + security_parameters.current_cipher_suite)); if (rc < 0) return rc; rc = MHD_gtls_set_kx (session, MHD_gtls_cipher_suite_get_kx_algo - (&session->security_parameters. - current_cipher_suite)); + (&session-> + security_parameters.current_cipher_suite)); if (rc < 0) return rc; rc = MHD_gtls_set_read_compression (session, - session->internals. - compression_method); + session-> + internals.compression_method); if (rc < 0) return rc; } else { /* RESUME_TRUE */ MHD__gnutls_cpy_read_security_parameters (&session->security_parameters, - &session->internals. - resumed_security_parameters); + &session-> + internals.resumed_security_parameters); } @@ -541,10 +546,10 @@ MHD_gtls_read_connection_state_init (MHD_gtls_session_t session) return rc; MHD__gnutls_handshake_log ("HSK[%x]: Cipher Suite: %s\n", - session, - MHD_gtls_cipher_suite_get_name - (&session->security_parameters. - current_cipher_suite)); + session, + MHD_gtls_cipher_suite_get_name + (&session-> + security_parameters.current_cipher_suite)); if (MHD_gtls_compression_is_ok (session->security_parameters.read_compression_algorithm) != 0) @@ -574,8 +579,8 @@ MHD_gtls_read_connection_state_init (MHD_gtls_session_t session) mac_size = - MHD_gnutls_hash_get_algo_len (session->security_parameters. - read_mac_algorithm); + MHD_gnutls_hash_get_algo_len (session-> + security_parameters.read_mac_algorithm); MHD__gnutls_handshake_log ("HSK[%x]: Initializing internal [read] cipher sessions\n", session); @@ -586,8 +591,8 @@ MHD_gtls_read_connection_state_init (MHD_gtls_session_t session) /* initialize cipher session */ session->connection_state.read_cipher_state = - MHD_gtls_cipher_init (session->security_parameters. - read_bulk_cipher_algorithm, + MHD_gtls_cipher_init (session-> + security_parameters.read_bulk_cipher_algorithm, &session->cipher_specs.client_write_key, &session->cipher_specs.client_write_IV); if (session->connection_state.read_cipher_state == GNUTLS_CIPHER_FAILED @@ -603,11 +608,10 @@ MHD_gtls_read_connection_state_init (MHD_gtls_session_t session) */ if (mac_size > 0) { - if (MHD__gnutls_sset_datum (&session->connection_state.read_mac_secret, - session->cipher_specs. - client_write_mac_secret.data, - session->cipher_specs. - client_write_mac_secret.size) < 0) + if (MHD__gnutls_sset_datum + (&session->connection_state.read_mac_secret, + session->cipher_specs.client_write_mac_secret.data, + session->cipher_specs.client_write_mac_secret.size) < 0) { MHD_gnutls_assert (); return GNUTLS_E_MEMORY_ERROR; @@ -619,8 +623,8 @@ MHD_gtls_read_connection_state_init (MHD_gtls_session_t session) #if MHD_DEBUG_TLS case GNUTLS_CLIENT: session->connection_state.read_cipher_state = - MHD_gtls_cipher_init (session->security_parameters. - read_bulk_cipher_algorithm, + MHD_gtls_cipher_init (session-> + security_parameters.read_bulk_cipher_algorithm, &session->cipher_specs.server_write_key, &session->cipher_specs.server_write_IV); @@ -638,11 +642,10 @@ MHD_gtls_read_connection_state_init (MHD_gtls_session_t session) */ if (mac_size > 0) { - if (MHD__gnutls_sset_datum (&session->connection_state.read_mac_secret, - session->cipher_specs. - server_write_mac_secret.data, - session->cipher_specs. - server_write_mac_secret.size) < 0) + if (MHD__gnutls_sset_datum + (&session->connection_state.read_mac_secret, + session->cipher_specs.server_write_mac_secret.data, + session->cipher_specs.server_write_mac_secret.size) < 0) { MHD_gnutls_assert (); return GNUTLS_E_MEMORY_ERROR; @@ -657,8 +660,8 @@ MHD_gtls_read_connection_state_init (MHD_gtls_session_t session) } session->connection_state.read_compression_state = - MHD_gtls_comp_init (session->security_parameters. - read_compression_algorithm, 1); + MHD_gtls_comp_init (session-> + security_parameters.read_compression_algorithm, 1); if (session->connection_state.read_compression_state == GNUTLS_COMP_FAILED) { @@ -689,35 +692,36 @@ MHD_gtls_write_connection_state_init (MHD_gtls_session_t session) { rc = MHD_gtls_set_write_cipher (session, MHD_gtls_cipher_suite_get_cipher_algo - (&session->security_parameters. - current_cipher_suite)); + (&session-> + security_parameters.current_cipher_suite)); if (rc < 0) return rc; rc = MHD_gtls_set_write_mac (session, MHD_gtls_cipher_suite_get_mac_algo - (&session->security_parameters. - current_cipher_suite)); + (&session-> + security_parameters.current_cipher_suite)); if (rc < 0) return rc; rc = MHD_gtls_set_kx (session, MHD_gtls_cipher_suite_get_kx_algo - (&session->security_parameters. - current_cipher_suite)); + (&session-> + security_parameters.current_cipher_suite)); if (rc < 0) return rc; rc = MHD_gtls_set_write_compression (session, - session->internals. - compression_method); + session-> + internals.compression_method); if (rc < 0) return rc; } else { /* RESUME_TRUE */ - MHD__gnutls_cpy_write_security_parameters (&session->security_parameters, - &session->internals. - resumed_security_parameters); + MHD__gnutls_cpy_write_security_parameters (&session-> + security_parameters, + &session-> + internals.resumed_security_parameters); } rc = MHD__gnutls_set_write_keys (session); @@ -725,9 +729,9 @@ MHD_gtls_write_connection_state_init (MHD_gtls_session_t session) return rc; MHD__gnutls_handshake_log ("HSK[%x]: Cipher Suite: %s\n", session, - MHD_gtls_cipher_suite_get_name - (&session->security_parameters. - current_cipher_suite)); + MHD_gtls_cipher_suite_get_name + (&session-> + security_parameters.current_cipher_suite)); if (MHD_gtls_compression_is_ok (session->security_parameters.write_compression_algorithm) != 0) @@ -758,8 +762,8 @@ MHD_gtls_write_connection_state_init (MHD_gtls_session_t session) 0); mac_size = - MHD_gnutls_hash_get_algo_len (session->security_parameters. - write_mac_algorithm); + MHD_gnutls_hash_get_algo_len (session-> + security_parameters.write_mac_algorithm); MHD__gnutls_handshake_log ("HSK[%x]: Initializing internal [write] cipher sessions\n", session); @@ -770,8 +774,8 @@ MHD_gtls_write_connection_state_init (MHD_gtls_session_t session) /* initialize cipher session */ session->connection_state.write_cipher_state = - MHD_gtls_cipher_init (session->security_parameters. - write_bulk_cipher_algorithm, + MHD_gtls_cipher_init (session-> + security_parameters.write_bulk_cipher_algorithm, &session->cipher_specs.server_write_key, &session->cipher_specs.server_write_IV); @@ -790,11 +794,10 @@ MHD_gtls_write_connection_state_init (MHD_gtls_session_t session) */ if (mac_size > 0) { - if (MHD__gnutls_sset_datum (&session->connection_state.write_mac_secret, - session->cipher_specs. - server_write_mac_secret.data, - session->cipher_specs. - server_write_mac_secret.size) < 0) + if (MHD__gnutls_sset_datum + (&session->connection_state.write_mac_secret, + session->cipher_specs.server_write_mac_secret.data, + session->cipher_specs.server_write_mac_secret.size) < 0) { MHD_gnutls_assert (); return GNUTLS_E_MEMORY_ERROR; @@ -807,8 +810,8 @@ MHD_gtls_write_connection_state_init (MHD_gtls_session_t session) #if MHD_DEBUG_TLS case GNUTLS_CLIENT: session->connection_state.write_cipher_state = - MHD_gtls_cipher_init (session->security_parameters. - write_bulk_cipher_algorithm, + MHD_gtls_cipher_init (session-> + security_parameters.write_bulk_cipher_algorithm, &session->cipher_specs.client_write_key, &session->cipher_specs.client_write_IV); @@ -825,11 +828,10 @@ MHD_gtls_write_connection_state_init (MHD_gtls_session_t session) */ if (mac_size > 0) { - if (MHD__gnutls_sset_datum (&session->connection_state.write_mac_secret, - session->cipher_specs. - client_write_mac_secret.data, - session->cipher_specs. - client_write_mac_secret.size) < 0) + if (MHD__gnutls_sset_datum + (&session->connection_state.write_mac_secret, + session->cipher_specs.client_write_mac_secret.data, + session->cipher_specs.client_write_mac_secret.size) < 0) { MHD_gnutls_assert (); return GNUTLS_E_MEMORY_ERROR; @@ -845,8 +847,8 @@ MHD_gtls_write_connection_state_init (MHD_gtls_session_t session) session->connection_state.write_compression_state = - MHD_gtls_comp_init (session->security_parameters. - write_compression_algorithm, 0); + MHD_gtls_comp_init (session-> + security_parameters.write_compression_algorithm, 0); if (session->connection_state.write_compression_state == GNUTLS_COMP_FAILED) { diff --git a/src/daemon/https/tls/gnutls_datum.c b/src/daemon/https/tls/gnutls_datum.c @@ -104,7 +104,8 @@ MHD_gtls_datum_append_m (MHD_gnutls_datum_t * dst, const void *data, } void -MHD_gtls_free_datum_m (MHD_gnutls_datum_t * dat, MHD_gnutls_free_function gfree_func) +MHD_gtls_free_datum_m (MHD_gnutls_datum_t * dat, + MHD_gnutls_free_function gfree_func) { if (dat->data != NULL) gfree_func (dat->data); diff --git a/src/daemon/https/tls/gnutls_datum.h b/src/daemon/https/tls/gnutls_datum.h @@ -36,5 +36,6 @@ int MHD_gtls_datum_append_m (MHD_gnutls_datum_t * dat, const void *data, size_t data_size, MHD_gnutls_realloc_function); #define MHD__gnutls_datum_append(x,y,z) MHD_gtls_datum_append_m(x,y,z, MHD_gnutls_realloc) -void MHD_gtls_free_datum_m (MHD_gnutls_datum_t * dat, MHD_gnutls_free_function); +void MHD_gtls_free_datum_m (MHD_gnutls_datum_t * dat, + MHD_gnutls_free_function); #define MHD__gnutls_free_datum(x) MHD_gtls_free_datum_m(x, MHD_gnutls_free) diff --git a/src/daemon/https/tls/gnutls_dh_primes.c b/src/daemon/https/tls/gnutls_dh_primes.c @@ -198,7 +198,7 @@ MHD__gnutls_dh_params_deinit (MHD_gtls_dh_params_t dh_params) **/ int MHD__gnutls_dh_params_generate2 (MHD_gtls_dh_params_t params, - unsigned int bits) + unsigned int bits) { int ret; diff --git a/src/daemon/https/tls/gnutls_extensions.c b/src/daemon/https/tls/gnutls_extensions.c @@ -154,9 +154,9 @@ MHD_gtls_parse_extensions (MHD_gtls_session_t session, for (i = 0; i < session->internals.extensions_sent_size; i++) { MHD__gnutls_debug_log ("EXT[%d]: expecting extension '%s'\n", - session, - MHD_gtls_extension_get_name - (session->internals.extensions_sent[i])); + session, + MHD_gtls_extension_get_name + (session->internals.extensions_sent[i])); } #endif @@ -173,7 +173,7 @@ MHD_gtls_parse_extensions (MHD_gtls_session_t session, pos += 2; MHD__gnutls_debug_log ("EXT[%x]: Received extension '%s/%d'\n", session, - MHD_gtls_extension_get_name (type), type); + MHD_gtls_extension_get_name (type), type); if ((ret = MHD__gnutls_extension_list_check (session, type)) < 0) { @@ -217,8 +217,9 @@ MHD__gnutls_extension_list_add (MHD_gtls_session_t session, uint16_t type) { if (session->internals.extensions_sent_size < MAX_EXT_TYPES) { - session->internals.extensions_sent[session->internals. - extensions_sent_size] = type; + session->internals.extensions_sent[session-> + internals.extensions_sent_size] = + type; session->internals.extensions_sent_size++; } else @@ -288,7 +289,7 @@ MHD_gtls_gen_extensions (MHD_gtls_session_t session, opaque * data, MHD__gnutls_extension_list_add (session, p->type); MHD__gnutls_debug_log ("EXT[%x]: Sending extension %s\n", session, - MHD_gtls_extension_get_name (p->type)); + MHD_gtls_extension_get_name (p->type)); } else if (size < 0) { diff --git a/src/daemon/https/tls/gnutls_global.c b/src/daemon/https/tls/gnutls_global.c @@ -51,7 +51,7 @@ extern const ASN1_ARRAY_TYPE MHD_gnutlsMHD__asn1_tab[]; extern const ASN1_ARRAY_TYPE MHD_pkix_asn1_tab[]; LOG_FUNC MHD__gnutls_log_func; -int MHD__gnutls_log_level = 0; /* default log level */ +int MHD__gnutls_log_level = 0; /* default log level */ ASN1_TYPE MHD__gnutls_pkix1_asn; ASN1_TYPE MHD__gnutlsMHD__gnutls_asn; @@ -148,7 +148,7 @@ MHD_gtls_global_set_mem_functions (MHD_gnutls_alloc_function alloc_func, #ifdef DEBUG static void MHD__gnutls_gcry_log_handler (void *dummy, int level, - const char *fmt, va_list list) + const char *fmt, va_list list) { MHD_gtls_log (level, fmt, list); } @@ -213,7 +213,7 @@ MHD__gnutls_global_init (void) if (data.wVersion < requested) { MHD__gnutls_debug_log ("WSAStartup version check failed (%d < %d).\n", - data.wVersion, requested); + data.wVersion, requested); WSACleanup (); return GNUTLS_E_LIBRARY_VERSION_MISMATCH; } @@ -245,9 +245,10 @@ MHD__gnutls_global_init (void) } /* for gcrypt in order to be able to allocate memory */ - gcry_set_allocation_handler (MHD_gnutls_malloc, MHD_gnutls_secure_malloc, - MHD__gnutls_is_secure_memory, MHD_gnutls_realloc, - MHD_gnutls_free); + gcry_set_allocation_handler (MHD_gnutls_malloc, + MHD_gnutls_secure_malloc, + MHD__gnutls_is_secure_memory, + MHD_gnutls_realloc, MHD_gnutls_free); /* gcry_control (GCRYCTL_DISABLE_INTERNAL_LOCKING, NULL, 0); */ @@ -276,14 +277,17 @@ MHD__gnutls_global_init (void) * This should not deal with files in the final * version. */ - res = MHD__asn1_array2tree (MHD_pkix_asn1_tab, &MHD__gnutls_pkix1_asn, NULL); + res = + MHD__asn1_array2tree (MHD_pkix_asn1_tab, &MHD__gnutls_pkix1_asn, NULL); if (res != ASN1_SUCCESS) { result = MHD_gtls_asn2err (res); return result; } - res = MHD__asn1_array2tree (MHD_gnutlsMHD__asn1_tab, &MHD__gnutlsMHD__gnutls_asn, NULL); + res = + MHD__asn1_array2tree (MHD_gnutlsMHD__asn1_tab, + &MHD__gnutlsMHD__gnutls_asn, NULL); if (res != ASN1_SUCCESS) { MHD__asn1_delete_structure (&MHD__gnutls_pkix1_asn); @@ -341,7 +345,7 @@ MHD__gnutls_global_deinit (void) **/ void MHD__gnutls_transport_set_pull_function (MHD_gtls_session_t session, - MHD_gtls_pull_func pull_func) + MHD_gtls_pull_func pull_func) { session->internals.MHD__gnutls_pull_func = pull_func; } @@ -362,7 +366,7 @@ MHD__gnutls_transport_set_pull_function (MHD_gtls_session_t session, **/ void MHD__gnutls_transport_set_push_function (MHD_gtls_session_t session, - MHD_gtls_push_func push_func) + MHD_gtls_push_func push_func) { session->internals.MHD__gnutls_push_func = push_func; } diff --git a/src/daemon/https/tls/gnutls_handshake.c b/src/daemon/https/tls/gnutls_handshake.c @@ -67,12 +67,13 @@ static int MHD_gtls_remove_unwanted_ciphersuites (MHD_gtls_session_t session, - cipher_suite_st ** cipherSuites, - int numCipherSuites, - enum - MHD_GNUTLS_PublicKeyAlgorithm); -static int MHD_gtls_server_select_suite (MHD_gtls_session_t session, opaque * data, - int datalen); + cipher_suite_st ** + cipherSuites, + int numCipherSuites, + enum + MHD_GNUTLS_PublicKeyAlgorithm); +static int MHD_gtls_server_select_suite (MHD_gtls_session_t session, + opaque * data, int datalen); static int MHD_gtls_generate_session_id (opaque * session_id, uint8_t * len); @@ -86,7 +87,7 @@ static int MHD_gtls_handshake_client (MHD_gtls_session_t session); static int MHD__gnutls_server_select_comp_method (MHD_gtls_session_t session, - opaque * data, int datalen); + opaque * data, int datalen); /* Clears the handshake hash buffers and handles. @@ -119,8 +120,8 @@ resume_copy_required_values (MHD_gtls_session_t session) * hello message. */ memcpy (session->security_parameters.current_cipher_suite.suite, - session->internals.resumed_security_parameters. - current_cipher_suite.suite, 2); + session->internals.resumed_security_parameters.current_cipher_suite. + suite, 2); session->internals.compression_method = session->internals.resumed_security_parameters.read_compression_algorithm; @@ -132,8 +133,9 @@ resume_copy_required_values (MHD_gtls_session_t session) session->internals.resumed_security_parameters.entity; MHD_gtls_set_current_version (session, - session->internals. - resumed_security_parameters.version); + session-> + internals.resumed_security_parameters. + version); session->security_parameters.cert_type = session->internals.resumed_security_parameters.cert_type; @@ -157,7 +159,8 @@ resume_copy_required_values (MHD_gtls_session_t session) * **/ void -MHD__gnutls_handshake_set_max_packet_length (MHD_gtls_session_t session, size_t max) +MHD__gnutls_handshake_set_max_packet_length (MHD_gtls_session_t session, + size_t max) { session->internals.max_handshake_data_buffer_size = max; } @@ -215,11 +218,13 @@ MHD__gnutls_ssl3_finished (MHD_gtls_session_t session, int type, opaque * ret) MHD_gnutls_hash (td_sha, mesg, siz); MHD_gnutls_mac_deinit_ssl3_handshake (td_md5, ret, - session->security_parameters. - master_secret, TLS_MASTER_SIZE); + session-> + security_parameters.master_secret, + TLS_MASTER_SIZE); MHD_gnutls_mac_deinit_ssl3_handshake (td_sha, &ret[16], - session->security_parameters. - master_secret, TLS_MASTER_SIZE); + session-> + security_parameters.master_secret, + TLS_MASTER_SIZE); return 0; } @@ -255,7 +260,7 @@ MHD__gnutls_finished (MHD_gtls_session_t session, int type, void *ret) { MHD_gnutls_assert (); if (td_md5 != NULL) - MHD_gnutls_hash_deinit (td_md5, NULL); + MHD_gnutls_hash_deinit (td_md5, NULL); return GNUTLS_E_HASH_FAILED; } @@ -301,7 +306,7 @@ MHD_gtls_tls_create_random (opaque * dst) /* generate server random value */ MHD_gtls_write_uint32 (tim, dst); - if (MHD_gc_nonce ((char*) &dst[4], TLS_RANDOM_SIZE - 4) != GC_OK) + if (MHD_gc_nonce ((char *) &dst[4], TLS_RANDOM_SIZE - 4) != GC_OK) { MHD_gnutls_assert (); return GNUTLS_E_RANDOM_FAILED; @@ -377,7 +382,7 @@ MHD_gtls_user_hello_func (MHD_gtls_session_t session, */ static int MHD__gnutls_read_client_hello (MHD_gtls_session_t session, opaque * data, - int datalen) + int datalen) { uint8_t session_id_len; int pos = 0, ret = 0; @@ -390,7 +395,7 @@ MHD__gnutls_read_client_hello (MHD_gtls_session_t session, opaque * data, DECR_LEN (len, 2); MHD__gnutls_handshake_log ("HSK[%x]: Client's version: %d.%d\n", session, - data[pos], data[pos + 1]); + data[pos], data[pos + 1]); adv_version = MHD_gtls_version_get (data[pos], data[pos + 1]); set_adv_version (session, data[pos], data[pos + 1]); @@ -437,8 +442,8 @@ MHD__gnutls_read_client_hello (MHD_gtls_session_t session, opaque * data, else { MHD_gtls_generate_session_id (session->security_parameters.session_id, - &session->security_parameters. - session_id_size); + &session-> + security_parameters.session_id_size); session->internals.resumed = RESUME_FALSE; } @@ -573,18 +578,20 @@ MHD__gnutls_send_finished (MHD_gtls_session_t session, int again) return ret; } - if (MHD__gnutls_protocol_get_version (session) == MHD_GNUTLS_PROTOCOL_SSL3) + if (MHD__gnutls_protocol_get_version (session) == + MHD_GNUTLS_PROTOCOL_SSL3) { ret = MHD__gnutls_ssl3_finished (session, - session->security_parameters.entity, data); + session->security_parameters.entity, + data); data_size = 36; } else { /* TLS 1.0 */ ret = MHD__gnutls_finished (session, - session->security_parameters.entity, data); + session->security_parameters.entity, data); data_size = 12; } @@ -645,15 +652,15 @@ MHD__gnutls_recv_finished (MHD_gtls_session_t session) { ret = MHD__gnutls_ssl3_finished (session, - (session->security_parameters.entity + 1) % 2, - data); + (session->security_parameters.entity + + 1) % 2, data); } else { /* TLS 1.0 */ ret = MHD__gnutls_finished (session, - (session->security_parameters.entity + - 1) % 2, data); + (session->security_parameters.entity + + 1) % 2, data); } if (ret < 0) @@ -678,7 +685,7 @@ MHD__gnutls_recv_finished (MHD_gtls_session_t session) */ static int MHD__gnutls_server_find_pk_algos_in_ciphersuites (const opaque * - data, int datalen) + data, int datalen) { int j; enum MHD_GNUTLS_PublicKeyAlgorithm algo = GNUTLS_PK_NONE, prev_algo = 0; @@ -763,12 +770,13 @@ MHD_gtls_server_select_suite (MHD_gtls_session_t session, opaque * data, for (j = 0; j < datalen; j += 2) { memcpy (&cs.suite, &data[j], 2); - MHD__gnutls_handshake_log ("\t%s\n", MHD_gtls_cipher_suite_get_name (&cs)); + MHD__gnutls_handshake_log ("\t%s\n", + MHD_gtls_cipher_suite_get_name (&cs)); } MHD__gnutls_handshake_log ("HSK[%x]: Supported cipher suites: \n", session); for (j = 0; j < x; j++) MHD__gnutls_handshake_log ("\t%s\n", - MHD_gtls_cipher_suite_get_name (&ciphers[j])); + MHD_gtls_cipher_suite_get_name (&ciphers[j])); #endif memset (session->security_parameters.current_cipher_suite.suite, '\0', 2); @@ -806,9 +814,9 @@ finish: */ if (MHD_gtls_get_kx_cred (session, - MHD_gtls_cipher_suite_get_kx_algo (&session->security_parameters. - current_cipher_suite), &err) == NULL - && err != 0) + MHD_gtls_cipher_suite_get_kx_algo (&session-> + security_parameters.current_cipher_suite), + &err) == NULL && err != 0) { MHD_gnutls_assert (); return GNUTLS_E_INSUFFICIENT_CREDENTIALS; @@ -821,8 +829,8 @@ finish: */ session->internals.auth_struct = MHD_gtls_kx_auth_struct (MHD_gtls_cipher_suite_get_kx_algo - (&session->security_parameters. - current_cipher_suite)); + (&session-> + security_parameters.current_cipher_suite)); if (session->internals.auth_struct == NULL) { @@ -842,7 +850,7 @@ finish: */ static int MHD__gnutls_server_select_comp_method (MHD_gtls_session_t session, - opaque * data, int datalen) + opaque * data, int datalen) { int x, i, j; uint8_t *comps; @@ -871,8 +879,8 @@ MHD__gnutls_server_select_comp_method (MHD_gtls_session_t session, MHD__gnutls_handshake_log ("HSK[%x]: Selected Compression Method: %s\n", session, - MHD_gtls_compression_get_name (session->internals. - compression_method)); + MHD_gtls_compression_get_name (session-> + internals.compression_method)); return 0; @@ -896,7 +904,8 @@ MHD__gnutls_server_select_comp_method (MHD_gtls_session_t session, */ static int MHD__gnutls_send_empty_handshake (MHD_gtls_session_t session, - MHD_gnutls_handshake_description_t type, int again) + MHD_gnutls_handshake_description_t type, + int again) { opaque data = 0; opaque *ptr; @@ -913,8 +922,8 @@ MHD__gnutls_send_empty_handshake (MHD_gtls_session_t session, /* This function will hash the handshake message we sent. */ static int MHD__gnutls_handshake_hash_add_sent (MHD_gtls_session_t session, - MHD_gnutls_handshake_description_t type, - opaque * dataptr, uint32_t datalen) + MHD_gnutls_handshake_description_t type, + opaque * dataptr, uint32_t datalen) { int ret; @@ -987,7 +996,8 @@ MHD_gtls_send_handshake (MHD_gtls_session_t session, void *i_data, */ if (type != GNUTLS_HANDSHAKE_HELLO_REQUEST) if ((ret = - MHD__gnutls_handshake_hash_add_sent (session, type, data, datasize)) < 0) + MHD__gnutls_handshake_hash_add_sent (session, type, data, + datasize)) < 0) { MHD_gnutls_assert (); MHD_gnutls_afree (data); @@ -1001,7 +1011,8 @@ MHD_gtls_send_handshake (MHD_gtls_session_t session, void *i_data, data, datasize); MHD__gnutls_handshake_log ("HSK[%x]: %s was sent [%ld bytes]\n", - session, MHD__gnutls_handshake2str (type), datasize); + session, MHD__gnutls_handshake2str (type), + datasize); MHD_gnutls_afree (data); @@ -1017,8 +1028,9 @@ MHD_gtls_send_handshake (MHD_gtls_session_t session, void *i_data, #define SSL2_HEADERS 1 static int MHD__gnutls_recv_handshake_header (MHD_gtls_session_t session, - MHD_gnutls_handshake_description_t type, - MHD_gnutls_handshake_description_t * recv_type) + MHD_gnutls_handshake_description_t type, + MHD_gnutls_handshake_description_t * + recv_type) { int ret; uint32_t length32 = 0; @@ -1032,8 +1044,8 @@ MHD__gnutls_recv_handshake_header (MHD_gtls_session_t session, if (session->internals.handshake_header_buffer.header_size == handshake_header_size || (session->internals.v2_hello != 0 && type == GNUTLS_HANDSHAKE_CLIENT_HELLO - && session->internals. - handshake_header_buffer.packet_length > 0)) + && session->internals.handshake_header_buffer. + packet_length > 0)) { *recv_type = session->internals.handshake_header_buffer.recv_type; @@ -1076,11 +1088,13 @@ MHD__gnutls_recv_handshake_header (MHD_gtls_session_t session, MHD_gtls_handshake_io_recv_int (session, GNUTLS_HANDSHAKE, type, &dataptr - [session->internals. - handshake_header_buffer.header_size], + [session-> + internals.handshake_header_buffer. + header_size], HANDSHAKE_HEADER_SIZE - - session->internals. - handshake_header_buffer.header_size); + session-> + internals.handshake_header_buffer. + header_size); if (ret <= 0) { MHD_gnutls_assert (); @@ -1102,8 +1116,9 @@ MHD__gnutls_recv_handshake_header (MHD_gtls_session_t session, handshake_header_size = HANDSHAKE_HEADER_SIZE; MHD__gnutls_handshake_log ("HSK[%x]: %s was received [%ld bytes]\n", - session, MHD__gnutls_handshake2str (dataptr[0]), - length32 + HANDSHAKE_HEADER_SIZE); + session, + MHD__gnutls_handshake2str (dataptr[0]), + length32 + HANDSHAKE_HEADER_SIZE); } else @@ -1115,8 +1130,9 @@ MHD__gnutls_recv_handshake_header (MHD_gtls_session_t session, *recv_type = dataptr[0]; MHD__gnutls_handshake_log ("HSK[%x]: %s(v2) was received [%ld bytes]\n", - session, MHD__gnutls_handshake2str (*recv_type), - length32 + handshake_header_size); + session, + MHD__gnutls_handshake2str (*recv_type), + length32 + handshake_header_size); if (*recv_type != GNUTLS_HANDSHAKE_CLIENT_HELLO) { /* it should be one or nothing */ @@ -1147,9 +1163,10 @@ MHD__gnutls_recv_handshake_header (MHD_gtls_session_t session, */ static int MHD__gnutls_handshake_hash_add_recvd (MHD_gtls_session_t session, - MHD_gnutls_handshake_description_t recv_type, - opaque * header, uint16_t header_size, - opaque * dataptr, uint32_t datalen) + MHD_gnutls_handshake_description_t + recv_type, opaque * header, + uint16_t header_size, opaque * dataptr, + uint32_t datalen) { int ret; @@ -1195,7 +1212,8 @@ MHD__gnutls_handshake_hash_add_recvd (MHD_gtls_session_t session, */ int MHD_gtls_recv_handshake (MHD_gtls_session_t session, uint8_t ** data, - int *datalen, MHD_gnutls_handshake_description_t type, + int *datalen, + MHD_gnutls_handshake_description_t type, Optional optional) { int ret; @@ -1259,11 +1277,12 @@ MHD_gtls_recv_handshake (MHD_gtls_session_t session, uint8_t ** data, ret = MHD__gnutls_handshake_hash_add_recvd (session, recv_type, - session->internals. - handshake_header_buffer.header, - session->internals. - handshake_header_buffer.header_size, - dataptr, length32); + session-> + internals.handshake_header_buffer. + header, + session-> + internals.handshake_header_buffer. + header_size, dataptr, length32); if (ret < 0) { MHD_gnutls_assert (); @@ -1319,7 +1338,8 @@ MHD_gtls_recv_handshake (MHD_gtls_session_t session, uint8_t ** data, * to the session; */ static int -MHD__gnutls_client_set_ciphersuite (MHD_gtls_session_t session, opaque suite[2]) +MHD__gnutls_client_set_ciphersuite (MHD_gtls_session_t session, + opaque suite[2]) { uint8_t z; cipher_suite_st *cipher_suites; @@ -1355,9 +1375,9 @@ MHD__gnutls_client_set_ciphersuite (MHD_gtls_session_t session, opaque suite[2]) memcpy (session->security_parameters.current_cipher_suite.suite, suite, 2); MHD__gnutls_handshake_log ("HSK[%x]: Selected cipher suite: %s\n", session, - MHD_gtls_cipher_suite_get_name - (&session->security_parameters. - current_cipher_suite)); + MHD_gtls_cipher_suite_get_name + (&session-> + security_parameters.current_cipher_suite)); /* check if the credentials (username, public key etc.) are ok. @@ -1380,8 +1400,8 @@ MHD__gnutls_client_set_ciphersuite (MHD_gtls_session_t session, opaque suite[2]) */ session->internals.auth_struct = MHD_gtls_kx_auth_struct (MHD_gtls_cipher_suite_get_kx_algo - (&session->security_parameters. - current_cipher_suite)); + (&session-> + security_parameters.current_cipher_suite)); if (session->internals.auth_struct == NULL) { @@ -1402,7 +1422,7 @@ MHD__gnutls_client_set_ciphersuite (MHD_gtls_session_t session, opaque suite[2]) */ static int MHD__gnutls_client_set_comp_method (MHD_gtls_session_t session, - opaque comp_method) + opaque comp_method) { int comp_methods_num; uint8_t *compression_methods; @@ -1446,16 +1466,15 @@ MHD__gnutls_client_set_comp_method (MHD_gtls_session_t session, */ static int MHD__gnutls_client_check_if_resuming (MHD_gtls_session_t session, - opaque * session_id, int session_id_len) + opaque * session_id, int session_id_len) { opaque buf[2 * TLS_MAX_SESSION_ID_SIZE + 1]; MHD__gnutls_handshake_log ("HSK[%x]: SessionID length: %d\n", session, - session_id_len); + session_id_len); MHD__gnutls_handshake_log ("HSK[%x]: SessionID: %s\n", session, - MHD_gtls_bin2hex (session_id, session_id_len, - (char*) buf, - sizeof (buf))); + MHD_gtls_bin2hex (session_id, session_id_len, + (char *) buf, sizeof (buf))); if (session_id_len > 0 && session->internals.resumed_security_parameters.session_id_size == @@ -1491,7 +1510,7 @@ MHD__gnutls_client_check_if_resuming (MHD_gtls_session_t session, */ static int MHD__gnutls_read_server_hello (MHD_gtls_session_t session, - opaque * data, int datalen) + opaque * data, int datalen) { uint8_t session_id_len = 0; int pos = 0; @@ -1506,7 +1525,7 @@ MHD__gnutls_read_server_hello (MHD_gtls_session_t session, } MHD__gnutls_handshake_log ("HSK[%x]: Server's version: %d.%d\n", - session, data[pos], data[pos + 1]); + session, data[pos], data[pos + 1]); DECR_LEN (len, 2); version = MHD_gtls_version_get (data[pos], data[pos + 1]); @@ -1594,7 +1613,7 @@ MHD__gnutls_read_server_hello (MHD_gtls_session_t session, */ static int MHD__gnutls_copy_ciphersuites (MHD_gtls_session_t session, - opaque * ret_data, size_t ret_data_size) + opaque * ret_data, size_t ret_data_size) { int ret, i; cipher_suite_st *cipher_suites; @@ -1662,7 +1681,7 @@ MHD__gnutls_copy_ciphersuites (MHD_gtls_session_t session, */ static int MHD__gnutls_copy_comp_methods (MHD_gtls_session_t session, - opaque * ret_data, size_t ret_data_size) + opaque * ret_data, size_t ret_data_size) { int ret, i; uint8_t *compression_methods, comp_num; @@ -1921,7 +1940,7 @@ MHD__gnutls_send_server_hello (MHD_gtls_session_t session, int again) */ MHD_gnutls_assert (); ret = MHD__gnutls_alert_send (session, GNUTLS_AL_FATAL, - GNUTLS_A_UNKNOWN_PSK_IDENTITY); + GNUTLS_A_UNKNOWN_PSK_IDENTITY); if (ret < 0) { MHD_gnutls_assert (); @@ -1969,16 +1988,17 @@ MHD__gnutls_send_server_hello (MHD_gtls_session_t session, int again) pos += session_id_len; MHD__gnutls_handshake_log ("HSK[%x]: SessionID: %s\n", session, - MHD_gtls_bin2hex (SessionID, session_id_len, - (char*) buf, sizeof (buf))); + MHD_gtls_bin2hex (SessionID, session_id_len, + (char *) buf, + sizeof (buf))); memcpy (&data[pos], session->security_parameters.current_cipher_suite.suite, 2); pos += 2; comp = - (uint8_t) MHD_gtls_compression_get_num (session-> - internals.compression_method); + (uint8_t) MHD_gtls_compression_get_num (session->internals. + compression_method); data[pos++] = comp; @@ -2103,7 +2123,7 @@ MHD__gnutls_rehandshake (MHD_gtls_session_t session) ret = MHD__gnutls_send_empty_handshake (session, GNUTLS_HANDSHAKE_HELLO_REQUEST, - AGAIN (STATE50)); + AGAIN (STATE50)); STATE = STATE50; if (ret < 0) @@ -2260,14 +2280,14 @@ MHD__gnutls_handshake (MHD_gtls_session_t session) } #if MHD_DEBUG_TLS if (session->security_parameters.entity == GNUTLS_CLIENT) - { - ret = MHD_gtls_handshake_client (session); - } - else + { + ret = MHD_gtls_handshake_client (session); + } + else #endif - { - ret = MHD_gtls_handshake_server (session); - } + { + ret = MHD_gtls_handshake_server (session); + } if (ret < 0) { @@ -2323,13 +2343,11 @@ MHD_gtls_handshake_client (MHD_gtls_session_t session) if (session->internals.resumed_security_parameters.session_id_size > 0) MHD__gnutls_handshake_log ("HSK[%x]: Ask to resume: %s\n", session, - MHD_gtls_bin2hex (session->internals. - resumed_security_parameters. - session_id, - session->internals. - resumed_security_parameters. - session_id_size, buf, - sizeof (buf))); + MHD_gtls_bin2hex (session-> + internals.resumed_security_parameters.session_id, + session-> + internals.resumed_security_parameters.session_id_size, + buf, sizeof (buf))); #endif switch (STATE) @@ -2613,8 +2631,8 @@ MHD_gtls_handshake_server (MHD_gtls_session_t session) if (session->internals.resumed == RESUME_FALSE) /* if we are not resuming */ ret = MHD__gnutls_send_empty_handshake (session, - GNUTLS_HANDSHAKE_SERVER_HELLO_DONE, - AGAIN (STATE6)); + GNUTLS_HANDSHAKE_SERVER_HELLO_DONE, + AGAIN (STATE6)); STATE = STATE6; IMED_RET ("send server hello done", ret); @@ -2696,7 +2714,7 @@ MHD_gtls_generate_session_id (opaque * session_id, uint8_t * len) { *len = TLS_MAX_SESSION_ID_SIZE; - if (MHD_gc_nonce ((char*) session_id, *len) != GC_OK) + if (MHD_gc_nonce ((char *) session_id, *len) != GC_OK) { MHD_gnutls_assert (); return GNUTLS_E_RANDOM_FAILED; @@ -2804,7 +2822,8 @@ check_server_params (MHD_gtls_session_t session, { MHD_gnutls_psk_server_credentials_t psk_cred = (MHD_gnutls_psk_server_credentials_t) MHD_gtls_get_cred (session->key, - cred_type, NULL); + cred_type, + NULL); if (psk_cred != NULL) { @@ -2889,8 +2908,9 @@ MHD_gtls_remove_unwanted_ciphersuites (MHD_gtls_session_t session, if (ret < 0) { MHD_gnutls_assert (); - MHD__gnutls_x509_log ("Could not find an appropriate certificate: %s\n", - MHD_gtls_strerror (ret)); + MHD__gnutls_x509_log + ("Could not find an appropriate certificate: %s\n", + MHD_gtls_strerror (ret)); cert_cred = NULL; } } @@ -2954,8 +2974,8 @@ MHD_gtls_remove_unwanted_ciphersuites (MHD_gtls_session_t session, { MHD__gnutls_handshake_log ("HSK[%x]: Keeping ciphersuite: %s\n", - session, - MHD_gtls_cipher_suite_get_name (&cs)); + session, + MHD_gtls_cipher_suite_get_name (&cs)); memcpy (newSuite[newSuiteSize].suite, (*cipherSuites)[i].suite, 2); newSuiteSize++; @@ -2963,8 +2983,8 @@ MHD_gtls_remove_unwanted_ciphersuites (MHD_gtls_session_t session, else { MHD__gnutls_handshake_log ("HSK[%x]: Removing ciphersuite: %s\n", - session, - MHD_gtls_cipher_suite_get_name (&cs)); + session, + MHD_gtls_cipher_suite_get_name (&cs)); } } diff --git a/src/daemon/https/tls/gnutls_handshake.h b/src/daemon/https/tls/gnutls_handshake.h @@ -37,7 +37,8 @@ int MHD_gtls_recv_handshake (MHD_gtls_session_t session, uint8_t **, int *, MHD_gnutls_handshake_description_t, Optional optional); void -MHD__gnutls_handshake_set_max_packet_length (MHD_gtls_session_t session, size_t max); +MHD__gnutls_handshake_set_max_packet_length (MHD_gtls_session_t session, + size_t max); #define STATE session->internals.handshake_state /* This returns true if we have got there diff --git a/src/daemon/https/tls/gnutls_hash_int.c b/src/daemon/https/tls/gnutls_hash_int.c @@ -133,7 +133,7 @@ MHD_gnutls_hash_deinit (GNUTLS_HASH_HANDLE handle, void *digest) maclen = MHD_gnutls_hash_get_algo_len (handle->algorithm); - mac = (unsigned char*) MHD_gc_hash_read (handle->handle); + mac = (unsigned char *) MHD_gc_hash_read (handle->handle); if (digest != NULL) memcpy (digest, mac, maclen); @@ -145,7 +145,7 @@ MHD_gnutls_hash_deinit (GNUTLS_HASH_HANDLE handle, void *digest) mac_hd_t MHD_gtls_MHD_hmac_init (enum MHD_GNUTLS_HashAlgorithm algorithm, - const void *key, int keylen) + const void *key, int keylen) { mac_hd_t ret; int result; @@ -154,7 +154,8 @@ MHD_gtls_MHD_hmac_init (enum MHD_GNUTLS_HashAlgorithm algorithm, if (ret == NULL) return GNUTLS_MAC_FAILED; - result = MHD_gc_hash_open (MHD__gnutls_mac2gc (algorithm), GC_HMAC, &ret->handle); + result = + MHD_gc_hash_open (MHD__gnutls_mac2gc (algorithm), GC_HMAC, &ret->handle); if (result) { MHD_gnutls_free (ret); @@ -178,7 +179,7 @@ MHD_gnutls_MHD_hmac_deinit (mac_hd_t handle, void *digest) maclen = MHD_gnutls_hash_get_algo_len (handle->algorithm); - mac = (unsigned char*) MHD_gc_hash_read (handle->handle); + mac = (unsigned char *) MHD_gc_hash_read (handle->handle); if (digest != NULL) memcpy (digest, mac, maclen); diff --git a/src/daemon/https/tls/gnutls_hash_int.h b/src/daemon/https/tls/gnutls_hash_int.h @@ -43,7 +43,7 @@ typedef mac_hd_t GNUTLS_HASH_HANDLE; #define GNUTLS_MAC_FAILED NULL mac_hd_t MHD_gtls_MHD_hmac_init (enum MHD_GNUTLS_HashAlgorithm algorithm, - const void *key, int keylen); + const void *key, int keylen); void MHD_gnutls_MHD_hmac_deinit (mac_hd_t handle, void *digest); diff --git a/src/daemon/https/tls/gnutls_kx.c b/src/daemon/https/tls/gnutls_kx.c @@ -62,14 +62,16 @@ generate_normal_master (MHD_gtls_session_t session, int keep_premaster) char buf[512]; MHD__gnutls_hard_log ("INT: PREMASTER SECRET[%d]: %s\n", PREMASTER.size, - MHD_gtls_bin2hex (PREMASTER.data, PREMASTER.size, buf, - sizeof (buf))); + MHD_gtls_bin2hex (PREMASTER.data, PREMASTER.size, buf, + sizeof (buf))); MHD__gnutls_hard_log ("INT: CLIENT RANDOM[%d]: %s\n", 32, - MHD_gtls_bin2hex (session->security_parameters. - client_random, 32, buf, sizeof (buf))); + MHD_gtls_bin2hex (session-> + security_parameters.client_random, + 32, buf, sizeof (buf))); MHD__gnutls_hard_log ("INT: SERVER RANDOM[%d]: %s\n", 32, - MHD_gtls_bin2hex (session->security_parameters. - server_random, 32, buf, sizeof (buf))); + MHD_gtls_bin2hex (session-> + security_parameters.server_random, + 32, buf, sizeof (buf))); if (MHD__gnutls_protocol_get_version (session) == MHD_GNUTLS_PROTOCOL_SSL3) { @@ -84,8 +86,8 @@ generate_normal_master (MHD_gtls_session_t session, int keep_premaster) MHD_gnutls_ssl3_generate_random (PREMASTER.data, PREMASTER.size, rnd, 2 * TLS_RANDOM_SIZE, TLS_MASTER_SIZE, - session->security_parameters. - master_secret); + session-> + security_parameters.master_secret); } else if (session->security_parameters.extensions.oprfi_client_len > 0 && @@ -105,21 +107,25 @@ generate_normal_master (MHD_gtls_session_t session, int keep_premaster) } MHD__gnutls_hard_log ("INT: CLIENT OPRFI[%d]: %s\n", - session->security_parameters. - extensions.oprfi_server_len, - MHD_gtls_bin2hex (session->security_parameters. - extensions.oprfi_client, - session->security_parameters. - extensions.oprfi_client_len, buf, - sizeof (buf))); + session->security_parameters.extensions. + oprfi_server_len, + MHD_gtls_bin2hex (session-> + security_parameters.extensions. + oprfi_client, + session-> + security_parameters.extensions. + oprfi_client_len, buf, + sizeof (buf))); MHD__gnutls_hard_log ("INT: SERVER OPRFI[%d]: %s\n", - session->security_parameters. - extensions.oprfi_server_len, - MHD_gtls_bin2hex (session->security_parameters. - extensions.oprfi_server, - session->security_parameters. - extensions.oprfi_server_len, buf, - sizeof (buf))); + session->security_parameters.extensions. + oprfi_server_len, + MHD_gtls_bin2hex (session-> + security_parameters.extensions. + oprfi_server, + session-> + security_parameters.extensions. + oprfi_server_len, buf, + sizeof (buf))); memcpy (rnd, session->security_parameters.client_random, TLS_RANDOM_SIZE); @@ -169,9 +175,10 @@ generate_normal_master (MHD_gtls_session_t session, int keep_premaster) return ret; MHD__gnutls_hard_log ("INT: MASTER SECRET: %s\n", - MHD_gtls_bin2hex (session->security_parameters. - master_secret, TLS_MASTER_SIZE, buf, - sizeof (buf))); + MHD_gtls_bin2hex (session-> + security_parameters.master_secret, + TLS_MASTER_SIZE, buf, + sizeof (buf))); return ret; } @@ -237,8 +244,8 @@ MHD_gtls_send_server_certificate_request (MHD_gtls_session_t session, int data_size = 0; int ret = 0; - if (session->internals.auth_struct-> - MHD_gtls_gen_server_certificate_request == NULL) + if (session->internals. + auth_struct->MHD_gtls_gen_server_certificate_request == NULL) return 0; if (session->internals.send_cert_req <= 0) @@ -250,8 +257,8 @@ MHD_gtls_send_server_certificate_request (MHD_gtls_session_t session, if (again == 0) { data_size = - session->internals.auth_struct-> - MHD_gtls_gen_server_certificate_request (session, &data); + session->internals. + auth_struct->MHD_gtls_gen_server_certificate_request (session, &data); if (data_size < 0) { @@ -350,8 +357,8 @@ MHD_gtls_send_client_certificate_verify (MHD_gtls_session_t session, if (again == 0) { data_size = - session->internals.auth_struct-> - MHD_gtls_gen_client_cert_vrfy (session, &data); + session->internals. + auth_struct->MHD_gtls_gen_client_cert_vrfy (session, &data); if (data_size < 0) { MHD_gnutls_assert (); @@ -423,8 +430,8 @@ MHD_gtls_recv_server_certificate_request (MHD_gtls_session_t session) int datasize; int ret = 0; - if (session->internals.auth_struct-> - MHD_gtls_process_server_certificate_request != NULL) + if (session->internals. + auth_struct->MHD_gtls_process_server_certificate_request != NULL) { ret = @@ -439,8 +446,10 @@ MHD_gtls_recv_server_certificate_request (MHD_gtls_session_t session) return 0; /* ignored */ ret = - session->internals.auth_struct-> - MHD_gtls_process_server_certificate_request (session, data, datasize); + session->internals. + auth_struct->MHD_gtls_process_server_certificate_request (session, + data, + datasize); MHD_gnutls_free (data); if (ret < 0) return ret; @@ -504,14 +513,15 @@ MHD_gtls_send_client_certificate (MHD_gtls_session_t session, int again) if (again == 0) { - if (MHD__gnutls_protocol_get_version (session) != MHD_GNUTLS_PROTOCOL_SSL3 || - session->internals.selected_cert_list_length > 0) + if (MHD__gnutls_protocol_get_version (session) != + MHD_GNUTLS_PROTOCOL_SSL3 + || session->internals.selected_cert_list_length > 0) { /* TLS 1.0 or SSL 3.0 with a valid certificate */ data_size = - session->internals.auth_struct-> - MHD_gtls_gen_client_certificate (session, &data); + session->internals. + auth_struct->MHD_gtls_gen_client_certificate (session, &data); if (data_size < 0) { @@ -525,12 +535,12 @@ MHD_gtls_send_client_certificate (MHD_gtls_session_t session, int again) * no certificate alert instead of an * empty certificate. */ - if (MHD__gnutls_protocol_get_version (session) == MHD_GNUTLS_PROTOCOL_SSL3 && - session->internals.selected_cert_list_length == 0) + if (MHD__gnutls_protocol_get_version (session) == MHD_GNUTLS_PROTOCOL_SSL3 + && session->internals.selected_cert_list_length == 0) { ret = MHD__gnutls_alert_send (session, GNUTLS_AL_WARNING, - GNUTLS_A_SSL3_NO_CERTIFICATE); + GNUTLS_A_SSL3_NO_CERTIFICATE); } else @@ -571,8 +581,8 @@ MHD_gtls_send_server_certificate (MHD_gtls_session_t session, int again) if (again == 0) { data_size = - session->internals.auth_struct-> - MHD_gtls_gen_server_certificate (session, &data); + session->internals. + auth_struct->MHD_gtls_gen_server_certificate (session, &data); if (data_size < 0) { @@ -632,8 +642,10 @@ MHD_gtls_recv_client_certificate (MHD_gtls_session_t session) */ if (optional == OPTIONAL_PACKET && ret == GNUTLS_E_WARNING_ALERT_RECEIVED && - MHD__gnutls_protocol_get_version (session) == MHD_GNUTLS_PROTOCOL_SSL3 && - MHD_gnutls_alert_get (session) == GNUTLS_A_SSL3_NO_CERTIFICATE) + MHD__gnutls_protocol_get_version (session) == + MHD_GNUTLS_PROTOCOL_SSL3 + && MHD_gnutls_alert_get (session) == + GNUTLS_A_SSL3_NO_CERTIFICATE) { /* SSL3 does not send an empty certificate, @@ -666,8 +678,9 @@ MHD_gtls_recv_client_certificate (MHD_gtls_session_t session) return 0; } ret = - session->internals.auth_struct-> - MHD_gtls_process_client_certificate (session, data, datasize); + session->internals. + auth_struct->MHD_gtls_process_client_certificate (session, data, + datasize); MHD_gnutls_free (data); if (ret < 0 && ret != GNUTLS_E_NO_CERTIFICATE_FOUND) @@ -711,8 +724,9 @@ MHD_gtls_recv_server_certificate (MHD_gtls_session_t session) } ret = - session->internals.auth_struct-> - MHD_gtls_process_server_certificate (session, data, datasize); + session->internals. + auth_struct->MHD_gtls_process_server_certificate (session, data, + datasize); MHD_gnutls_free (data); if (ret < 0) { @@ -763,8 +777,9 @@ MHD_gtls_recv_client_certificate_verify_message (MHD_gtls_session_t session) } ret = - session->internals.auth_struct-> - MHD_gtls_process_client_cert_vrfy (session, data, datasize); + session->internals. + auth_struct->MHD_gtls_process_client_cert_vrfy (session, data, + datasize); MHD_gnutls_free (data); if (ret < 0) return ret; diff --git a/src/daemon/https/tls/gnutls_mem.c b/src/daemon/https/tls/gnutls_mem.c @@ -40,7 +40,8 @@ MHD__gnutls_is_secure_mem_null (const void *ign) return 0; } -int (*MHD__gnutls_is_secure_memory) (const void *) = MHD__gnutls_is_secure_mem_null; +int (*MHD__gnutls_is_secure_memory) (const void *) = + MHD__gnutls_is_secure_mem_null; void * diff --git a/src/daemon/https/tls/gnutls_mpi.c b/src/daemon/https/tls/gnutls_mpi.c @@ -241,7 +241,8 @@ MHD__gnutls_x509_read_int (ASN1_TYPE node, const char *value, mpi_t * ret_mpi) /* Writes the specified integer into the specified node. */ int -MHD__gnutls_x509_write_int (ASN1_TYPE node, const char *value, mpi_t mpi, int lz) +MHD__gnutls_x509_write_int (ASN1_TYPE node, const char *value, mpi_t mpi, + int lz) { opaque *tmpstr; size_t s_len; diff --git a/src/daemon/https/tls/gnutls_pk.c b/src/daemon/https/tls/gnutls_pk.c @@ -41,13 +41,13 @@ #include "mpi.h" static int MHD__gnutls_pk_encrypt (int algo, mpi_t * resarr, mpi_t data, - mpi_t * pkey, int pkey_len); + mpi_t * pkey, int pkey_len); static int MHD__gnutls_pk_sign (int algo, mpi_t * data, mpi_t hash, - mpi_t * pkey, int); + mpi_t * pkey, int); static int MHD__gnutls_pk_verify (int algo, mpi_t hash, mpi_t * data, - mpi_t * pkey, int); + mpi_t * pkey, int); static int MHD__gnutls_pk_decrypt (int algo, mpi_t * resarr, mpi_t data, - mpi_t * pkey, int); + mpi_t * pkey, int); /* Do PKCS-1 RSA encryption. @@ -104,7 +104,7 @@ MHD_gtls_pkcs1_rsa_encrypt (MHD_gnutls_datum_t * ciphertext, return GNUTLS_E_INTERNAL_ERROR; } - if (MHD_gc_pseudo_random ((char*)ps, psize) != GC_OK) + if (MHD_gc_pseudo_random ((char *) ps, psize) != GC_OK) { MHD_gnutls_assert (); MHD_gnutls_afree (edata); @@ -113,7 +113,7 @@ MHD_gtls_pkcs1_rsa_encrypt (MHD_gnutls_datum_t * ciphertext, for (i = 0; i < psize; i++) while (ps[i] == 0) { - if (MHD_gc_pseudo_random ((char*) &ps[i], 1) != GC_OK) + if (MHD_gc_pseudo_random ((char *) &ps[i], 1) != GC_OK) { MHD_gnutls_assert (); MHD_gnutls_afree (edata); @@ -391,8 +391,8 @@ encode_ber_rs (MHD_gnutls_datum_t * sig_value, mpi_t r, mpi_t s) if ((result = MHD__asn1_create_element (MHD__gnutls_getMHD__gnutls_asn (), - "GNUTLS.DSASignatureValue", - &sig)) != ASN1_SUCCESS) + "GNUTLS.DSASignatureValue", + &sig)) != ASN1_SUCCESS) { MHD_gnutls_assert (); return MHD_gtls_asn2err (result); @@ -489,14 +489,15 @@ decode_ber_rs (const MHD_gnutls_datum_t * sig_value, mpi_t * r, mpi_t * s) if ((result = MHD__asn1_create_element (MHD__gnutls_getMHD__gnutls_asn (), - "GNUTLS.DSASignatureValue", - &sig)) != ASN1_SUCCESS) + "GNUTLS.DSASignatureValue", + &sig)) != ASN1_SUCCESS) { MHD_gnutls_assert (); return MHD_gtls_asn2err (result); } - result = MHD__asn1_der_decoding (&sig, sig_value->data, sig_value->size, NULL); + result = + MHD__asn1_der_decoding (&sig, sig_value->data, sig_value->size, NULL); if (result != ASN1_SUCCESS) { MHD_gnutls_assert (); @@ -585,7 +586,7 @@ MHD_gtls_dsa_verify (const MHD_gnutls_datum_t * vdata, */ static int MHD__gnutls_pk_encrypt (int algo, mpi_t * resarr, mpi_t data, - mpi_t * pkey, int pkey_len) + mpi_t * pkey, int pkey_len) { gcry_sexp_t s_ciph, s_data, s_pkey; int rc = -1; @@ -657,7 +658,7 @@ MHD__gnutls_pk_encrypt (int algo, mpi_t * resarr, mpi_t data, static int MHD__gnutls_pk_decrypt (int algo, mpi_t * resarr, mpi_t data, mpi_t * pkey, - int pkey_len) + int pkey_len) { gcry_sexp_t s_plain, s_data, s_pkey; int rc = -1; @@ -724,7 +725,7 @@ MHD__gnutls_pk_decrypt (int algo, mpi_t * resarr, mpi_t data, mpi_t * pkey, */ static int MHD__gnutls_pk_sign (int algo, mpi_t * data, mpi_t hash, mpi_t * pkey, - int pkey_len) + int pkey_len) { gcry_sexp_t s_hash, s_key, s_sig; int rc = -1; @@ -834,7 +835,7 @@ MHD__gnutls_pk_sign (int algo, mpi_t * data, mpi_t hash, mpi_t * pkey, static int MHD__gnutls_pk_verify (int algo, mpi_t hash, mpi_t * data, - mpi_t * pkey, int pkey_len) + mpi_t * pkey, int pkey_len) { gcry_sexp_t s_sig, s_hash, s_pkey; int rc = -1; diff --git a/src/daemon/https/tls/gnutls_pk.h b/src/daemon/https/tls/gnutls_pk.h @@ -37,8 +37,8 @@ int MHD_gtls_pkcs1_rsa_decrypt (MHD_gnutls_datum_t * plaintext, mpi_t * params, unsigned params_len, unsigned btype); int MHD_gtls_rsa_verify (const MHD_gnutls_datum_t * vdata, - const MHD_gnutls_datum_t * ciphertext, mpi_t * params, - int params_len, int btype); + const MHD_gnutls_datum_t * ciphertext, + mpi_t * params, int params_len, int btype); int MHD_gtls_dsa_verify (const MHD_gnutls_datum_t * vdata, const MHD_gnutls_datum_t * sig_value, mpi_t * params, int params_len); diff --git a/src/daemon/https/tls/gnutls_priority.c b/src/daemon/https/tls/gnutls_priority.c @@ -71,11 +71,10 @@ _set_priority (MHD_gtls_priority_st * st, const int *list) { int num = 0; - while ( (list[num] != 0) && - (num < MAX_ALGOS) ) + while ((list[num] != 0) && (num < MAX_ALGOS)) num++; st->num_algorithms = num; - memcpy(st->priority, list, num * sizeof(int)); + memcpy (st->priority, list, num * sizeof (int)); return 0; } @@ -142,7 +141,7 @@ MHD__gnutls_mac_set_priority (MHD_gtls_session_t session, const int *list) **/ int MHD__gnutls_compression_set_priority (MHD_gtls_session_t session, - const int *list) + const int *list) { return _set_priority (&session->internals.priorities.compression, list); } @@ -160,7 +159,8 @@ MHD__gnutls_compression_set_priority (MHD_gtls_session_t session, * **/ int -MHD__gnutls_protocol_set_priority (MHD_gtls_session_t session, const int *list) +MHD__gnutls_protocol_set_priority (MHD_gtls_session_t session, + const int *list) { int ret; @@ -190,7 +190,7 @@ MHD__gnutls_protocol_set_priority (MHD_gtls_session_t session, const int *list) **/ int MHD__gnutls_certificate_type_set_priority (MHD_gtls_session_t session, - const int *list) + const int *list) { #if ENABLE_OPENPGP return _set_priority (&session->internals.priorities.cert_type, list); @@ -243,7 +243,7 @@ typedef void (rmadd_func) (MHD_gtls_priority_st * priority_list, int alg); **/ int MHD__gnutls_priority_set (MHD_gtls_session_t session, - MHD_gnutls_priority_t priority) + MHD_gnutls_priority_t priority) { if (priority == NULL) { @@ -326,7 +326,8 @@ int MHD_tls_set_default_priority (MHD_gnutls_priority_t * priority_cache, const char *priorities, const char **err_pos) { - *priority_cache = MHD_gnutls_calloc (1, sizeof (struct MHD_gtls_priority_st)); + *priority_cache = + MHD_gnutls_calloc (1, sizeof (struct MHD_gtls_priority_st)); if (*priority_cache == NULL) { MHD_gnutls_assert (); @@ -375,7 +376,7 @@ MHD__gnutls_priority_deinit (MHD_gnutls_priority_t priority_cache) **/ int MHD__gnutls_priority_set_direct (MHD_gtls_session_t session, - const char *priorities, const char **err_pos) + const char *priorities, const char **err_pos) { MHD_gnutls_priority_t prio; int ret; diff --git a/src/daemon/https/tls/gnutls_record.c b/src/daemon/https/tls/gnutls_record.c @@ -109,7 +109,7 @@ MHD_gtls_record_disable_padding (MHD_gtls_session_t session) **/ void MHD__gnutls_transport_set_ptr (MHD_gtls_session_t session, - MHD_gnutls_transport_ptr_t ptr) + MHD_gnutls_transport_ptr_t ptr) { session->internals.transport_recv_ptr = ptr; session->internals.transport_send_ptr = ptr; @@ -128,8 +128,8 @@ MHD__gnutls_transport_set_ptr (MHD_gtls_session_t session, **/ void MHD__gnutls_transport_set_ptr2 (MHD_gtls_session_t session, - MHD_gnutls_transport_ptr_t recv_ptr, - MHD_gnutls_transport_ptr_t send_ptr) + MHD_gnutls_transport_ptr_t recv_ptr, + MHD_gnutls_transport_ptr_t send_ptr) { session->internals.transport_send_ptr = send_ptr; session->internals.transport_recv_ptr = recv_ptr; @@ -188,7 +188,7 @@ MHD__gnutls_bye (MHD_gtls_session_t session, MHD_gnutls_close_request_t how) case STATE61: ret = MHD__gnutls_alert_send (session, GNUTLS_AL_WARNING, - GNUTLS_A_CLOSE_NOTIFY); + GNUTLS_A_CLOSE_NOTIFY); STATE = STATE61; if (ret < 0) { @@ -258,7 +258,8 @@ session_is_valid (MHD_gtls_session_t session) */ inline static void copy_record_version (MHD_gtls_session_t session, - MHD_gnutls_handshake_description_t htype, opaque version[2]) + MHD_gnutls_handshake_description_t htype, + opaque version[2]) { enum MHD_GNUTLS_Protocol lver; @@ -331,8 +332,8 @@ MHD_gtls_send_int (MHD_gtls_session_t session, MHD__gnutls_record_log ("REC[%x]: Sending Packet[%d] %s(%d) with length: %d\n", session, - (int) MHD_gtls_uint64touint32 (&session->connection_state. - write_sequence_number), + (int) MHD_gtls_uint64touint32 (&session-> + connection_state.write_sequence_number), MHD__gnutls_packet2str (type), type, sizeofdata); if (sizeofdata > MAX_RECORD_SEND_SIZE) @@ -424,11 +425,11 @@ MHD_gtls_send_int (MHD_gtls_session_t session, session->internals.record_send_buffer_user_size = 0; MHD__gnutls_record_log ("REC[%x]: Sent Packet[%d] %s(%d) with length: %d\n", - session, - (int) - MHD_gtls_uint64touint32 - (&session->connection_state.write_sequence_number), - MHD__gnutls_packet2str (type), type, cipher_size); + session, + (int) + MHD_gtls_uint64touint32 + (&session->connection_state.write_sequence_number), + MHD__gnutls_packet2str (type), type, cipher_size); return retval; } @@ -547,7 +548,7 @@ record_check_headers (MHD_gtls_session_t session, session->internals.v2_hello = *length; MHD__gnutls_record_log ("REC[%x]: V2 packet received. Length: %d\n", - session, *length); + session, *length); } else @@ -570,7 +571,8 @@ record_check_headers (MHD_gtls_session_t session, */ inline static int record_check_version (MHD_gtls_session_t session, - MHD_gnutls_handshake_description_t htype, opaque version[2]) + MHD_gnutls_handshake_description_t htype, + opaque version[2]) { if (htype == GNUTLS_HANDSHAKE_CLIENT_HELLO) { @@ -595,7 +597,7 @@ record_check_version (MHD_gtls_session_t session, */ MHD_gnutls_assert (); MHD__gnutls_record_log ("REC[%x]: INVALID VERSION PACKET: (%d) %d.%d\n", - session, htype, version[0], version[1]); + session, htype, version[0], version[1]); return GNUTLS_E_UNSUPPORTED_VERSION_PACKET; } @@ -769,7 +771,8 @@ get_temp_recv_buffer (MHD_gtls_session_t session, MHD_gnutls_datum_t * tmp) */ session->internals.recv_buffer.data = - MHD_gnutls_realloc (session->internals.recv_buffer.data, max_record_size); + MHD_gnutls_realloc (session->internals.recv_buffer.data, + max_record_size); if (session->internals.recv_buffer.data == NULL) { @@ -895,15 +898,14 @@ begin: MHD__gnutls_record_log ("REC[%x]: Expected Packet[%d] %s(%d) with length: %d\n", session, - (int) MHD_gtls_uint64touint32 (&session->connection_state. - read_sequence_number), + (int) MHD_gtls_uint64touint32 (&session-> + connection_state.read_sequence_number), MHD__gnutls_packet2str (type), type, sizeofdata); - MHD__gnutls_record_log ("REC[%x]: Received Packet[%d] %s(%d) with length: %d\n", - session, - (int) - MHD_gtls_uint64touint32 (&session->connection_state. - read_sequence_number), - MHD__gnutls_packet2str (recv_type), recv_type, length); + MHD__gnutls_record_log + ("REC[%x]: Received Packet[%d] %s(%d) with length: %d\n", session, + (int) MHD_gtls_uint64touint32 (&session-> + connection_state.read_sequence_number), + MHD__gnutls_packet2str (recv_type), recv_type, length); if (length > MAX_RECV_SIZE) { @@ -978,8 +980,8 @@ begin: MHD__gnutls_record_log ("REC[%x]: Decrypted Packet[%d] %s(%d) with length: %d\n", session, - (int) MHD_gtls_uint64touint32 (&session->connection_state. - read_sequence_number), + (int) MHD_gtls_uint64touint32 (&session-> + connection_state.read_sequence_number), MHD__gnutls_packet2str (recv_type), recv_type, decrypted_length); /* increase sequence number @@ -1082,7 +1084,7 @@ begin: **/ ssize_t MHD__gnutls_record_send (MHD_gtls_session_t session, - const void *data, size_t sizeofdata) + const void *data, size_t sizeofdata) { return MHD_gtls_send_int (session, GNUTLS_APPLICATION_DATA, -1, data, sizeofdata); @@ -1120,7 +1122,7 @@ MHD__gnutls_record_send (MHD_gtls_session_t session, **/ ssize_t MHD__gnutls_record_recv (MHD_gtls_session_t session, void *data, - size_t sizeofdata) + size_t sizeofdata) { return MHD_gtls_recv_int (session, GNUTLS_APPLICATION_DATA, -1, data, sizeofdata); diff --git a/src/daemon/https/tls/gnutls_rsa_export.c b/src/daemon/https/tls/gnutls_rsa_export.c @@ -61,4 +61,3 @@ MHD__gnutls_rsa_params_deinit (MHD_gtls_rsa_params_t rsa_params) { MHD_gnutls_x509_privkey_deinit (rsa_params); } - diff --git a/src/daemon/https/tls/gnutls_rsa_export.h b/src/daemon/https/tls/gnutls_rsa_export.h @@ -24,4 +24,3 @@ const mpi_t *MHD__gnutls_rsa_params_to_mpi (MHD_gtls_rsa_params_t); int MHD__gnutls_peers_cert_less_512 (MHD_gtls_session_t session); - diff --git a/src/daemon/https/tls/gnutls_session.c b/src/daemon/https/tls/gnutls_session.c @@ -69,4 +69,3 @@ MHD_gtls_session_get_id (MHD_gtls_session_t session, return 0; } - diff --git a/src/daemon/https/tls/gnutls_session_pack.c b/src/daemon/https/tls/gnutls_session_pack.c @@ -50,7 +50,8 @@ static int unpack_certificate_auth_info (MHD_gtls_session_t, packed_session); static int unpack_security_parameters (MHD_gtls_session_t session, - const MHD_gnutls_datum_t * packed_session); + const MHD_gnutls_datum_t * + packed_session); static int pack_security_parameters (MHD_gtls_session_t session, MHD_gnutls_datum_t * packed_session); @@ -180,7 +181,8 @@ unpack_anon_auth_info (MHD_gtls_session_t session, size = MHD_gtls_read_uint32 (&packed_session->data[pos]); pos += 4; - ret = MHD__gnutls_set_datum (&info->dh.prime, &packed_session->data[pos], size); + ret = + MHD__gnutls_set_datum (&info->dh.prime, &packed_session->data[pos], size); if (ret < 0) { MHD_gnutls_assert (); @@ -191,7 +193,8 @@ unpack_anon_auth_info (MHD_gtls_session_t session, size = MHD_gtls_read_uint32 (&packed_session->data[pos]); pos += 4; ret = - MHD__gnutls_set_datum (&info->dh.generator, &packed_session->data[pos], size); + MHD__gnutls_set_datum (&info->dh.generator, &packed_session->data[pos], + size); if (ret < 0) { MHD_gnutls_assert (); @@ -203,7 +206,7 @@ unpack_anon_auth_info (MHD_gtls_session_t session, pos += 4; ret = MHD__gnutls_set_datum (&info->dh.public_key, &packed_session->data[pos], - size); + size); if (ret < 0) { MHD_gnutls_assert (); @@ -534,7 +537,8 @@ unpack_certificate_auth_info (MHD_gtls_session_t session, size = MHD_gtls_read_uint32 (&packed_session->data[pos]); pos += 4; - ret = MHD__gnutls_set_datum (&info->dh.prime, &packed_session->data[pos], size); + ret = + MHD__gnutls_set_datum (&info->dh.prime, &packed_session->data[pos], size); if (ret < 0) { MHD_gnutls_assert (); @@ -545,7 +549,8 @@ unpack_certificate_auth_info (MHD_gtls_session_t session, size = MHD_gtls_read_uint32 (&packed_session->data[pos]); pos += 4; ret = - MHD__gnutls_set_datum (&info->dh.generator, &packed_session->data[pos], size); + MHD__gnutls_set_datum (&info->dh.generator, &packed_session->data[pos], + size); if (ret < 0) { MHD_gnutls_assert (); @@ -557,7 +562,7 @@ unpack_certificate_auth_info (MHD_gtls_session_t session, pos += 4; ret = MHD__gnutls_set_datum (&info->dh.public_key, &packed_session->data[pos], - size); + size); if (ret < 0) { MHD_gnutls_assert (); @@ -569,7 +574,7 @@ unpack_certificate_auth_info (MHD_gtls_session_t session, pos += 4; ret = MHD__gnutls_set_datum (&info->rsa_export.modulus, - &packed_session->data[pos], size); + &packed_session->data[pos], size); if (ret < 0) { MHD_gnutls_assert (); @@ -581,7 +586,7 @@ unpack_certificate_auth_info (MHD_gtls_session_t session, pos += 4; ret = MHD__gnutls_set_datum (&info->rsa_export.exponent, - &packed_session->data[pos], size); + &packed_session->data[pos], size); if (ret < 0) { MHD_gnutls_assert (); @@ -611,7 +616,7 @@ unpack_certificate_auth_info (MHD_gtls_session_t session, ret = MHD__gnutls_set_datum (&info->raw_certificate_list[i], - &packed_session->data[pos], size); + &packed_session->data[pos], size); pos += size; if (ret < 0) @@ -881,7 +886,8 @@ unpack_psk_auth_info (MHD_gtls_session_t session, size = MHD_gtls_read_uint32 (&packed_session->data[pos]); pos += 4; - ret = MHD__gnutls_set_datum (&info->dh.prime, &packed_session->data[pos], size); + ret = + MHD__gnutls_set_datum (&info->dh.prime, &packed_session->data[pos], size); if (ret < 0) { MHD_gnutls_assert (); @@ -892,7 +898,8 @@ unpack_psk_auth_info (MHD_gtls_session_t session, size = MHD_gtls_read_uint32 (&packed_session->data[pos]); pos += 4; ret = - MHD__gnutls_set_datum (&info->dh.generator, &packed_session->data[pos], size); + MHD__gnutls_set_datum (&info->dh.generator, &packed_session->data[pos], + size); if (ret < 0) { MHD_gnutls_assert (); @@ -904,7 +911,7 @@ unpack_psk_auth_info (MHD_gtls_session_t session, pos += 4; ret = MHD__gnutls_set_datum (&info->dh.public_key, &packed_session->data[pos], - size); + size); if (ret < 0) { MHD_gnutls_assert (); @@ -1045,8 +1052,9 @@ pack_security_parameters (MHD_gtls_session_t session, session->security_parameters.extensions.srp_username, len); pos += len; - MHD_gtls_write_uint16 (session->security_parameters.extensions. - server_names_size, &packed_session->data[pos]); + MHD_gtls_write_uint16 (session->security_parameters. + extensions.server_names_size, + &packed_session->data[pos]); pos += 2; for (i = 0; i < session->security_parameters.extensions.server_names_size; @@ -1054,15 +1062,15 @@ pack_security_parameters (MHD_gtls_session_t session, { packed_session->data[pos++] = session->security_parameters.extensions.server_names[i].type; - MHD_gtls_write_uint16 (session->security_parameters.extensions. - server_names[i].name_length, + MHD_gtls_write_uint16 (session->security_parameters. + extensions.server_names[i].name_length, &packed_session->data[pos]); pos += 2; memcpy (&packed_session->data[pos], session->security_parameters.extensions.server_names[i].name, - session->security_parameters.extensions.server_names[i]. - name_length); + session->security_parameters.extensions. + server_names[i].name_length); pos += session->security_parameters.extensions.server_names[i].name_length; } @@ -1121,10 +1129,10 @@ unpack_security_parameters (MHD_gtls_session_t session, packed_session->data[pos++]; session->internals.resumed_security_parameters.write_compression_algorithm = packed_session->data[pos++]; - session->internals.resumed_security_parameters.current_cipher_suite. - suite[0] = packed_session->data[pos++]; - session->internals.resumed_security_parameters.current_cipher_suite. - suite[1] = packed_session->data[pos++]; + session->internals.resumed_security_parameters. + current_cipher_suite.suite[0] = packed_session->data[pos++]; + session->internals.resumed_security_parameters. + current_cipher_suite.suite[1] = packed_session->data[pos++]; session->internals.resumed_security_parameters.cert_type = packed_session->data[pos++]; @@ -1173,34 +1181,35 @@ unpack_security_parameters (MHD_gtls_session_t session, /* SRP */ len = packed_session->data[pos++]; /* srp username length */ - memcpy (session->internals.resumed_security_parameters.extensions. - srp_username, &packed_session->data[pos], len); - session->internals.resumed_security_parameters.extensions. - srp_username[len] = 0; + memcpy (session->internals.resumed_security_parameters. + extensions.srp_username, &packed_session->data[pos], len); + session->internals.resumed_security_parameters. + extensions.srp_username[len] = 0; pos += len; - session->internals.resumed_security_parameters.extensions. - server_names_size = MHD_gtls_read_uint16 (&packed_session->data[pos]); + session->internals.resumed_security_parameters. + extensions.server_names_size = + MHD_gtls_read_uint16 (&packed_session->data[pos]); pos += 2; for (i = 0; i < - session->internals.resumed_security_parameters.extensions. - server_names_size; i++) + session->internals.resumed_security_parameters. + extensions.server_names_size; i++) { - session->internals.resumed_security_parameters.extensions. - server_names[i].type = packed_session->data[pos++]; - session->internals.resumed_security_parameters.extensions. - server_names[i].name_length = + session->internals.resumed_security_parameters. + extensions.server_names[i].type = packed_session->data[pos++]; + session->internals.resumed_security_parameters. + extensions.server_names[i].name_length = MHD_gtls_read_uint16 (&packed_session->data[pos]); pos += 2; - memcpy (session->internals.resumed_security_parameters.extensions. - server_names[i].name, &packed_session->data[pos], - session->internals.resumed_security_parameters.extensions. - server_names[i].name_length); + memcpy (session->internals.resumed_security_parameters. + extensions.server_names[i].name, &packed_session->data[pos], + session->internals.resumed_security_parameters. + extensions.server_names[i].name_length); pos += - session->internals.resumed_security_parameters.extensions. - server_names[i].name_length; + session->internals.resumed_security_parameters. + extensions.server_names[i].name_length; } return 0; } diff --git a/src/daemon/https/tls/gnutls_sig.c b/src/daemon/https/tls/gnutls_sig.c @@ -38,10 +38,10 @@ #include <gnutls_kx.h> static int MHD__gnutls_tls_sign (MHD_gtls_session_t session, - MHD_gnutls_cert * cert, - MHD_gnutls_privkey * pkey, - const MHD_gnutls_datum_t * hash_concat, - MHD_gnutls_datum_t * signature); + MHD_gnutls_cert * cert, + MHD_gnutls_privkey * pkey, + const MHD_gnutls_datum_t * hash_concat, + MHD_gnutls_datum_t * signature); /* Generates a signature of all the previous sent packets in the * handshake procedure. (20040227: now it works for SSL 3.0 as well) @@ -49,7 +49,8 @@ static int MHD__gnutls_tls_sign (MHD_gtls_session_t session, int MHD_gtls_tls_sign_hdata (MHD_gtls_session_t session, MHD_gnutls_cert * cert, - MHD_gnutls_privkey * pkey, MHD_gnutls_datum_t * signature) + MHD_gnutls_privkey * pkey, + MHD_gnutls_datum_t * signature) { MHD_gnutls_datum_t dconcat; int ret; @@ -75,8 +76,9 @@ MHD_gtls_tls_sign_hdata (MHD_gtls_session_t session, } MHD_gnutls_mac_deinit_ssl3_handshake (td_sha, &concat[16], - session->security_parameters. - master_secret, TLS_MASTER_SIZE); + session-> + security_parameters.master_secret, + TLS_MASTER_SIZE); } else MHD_gnutls_hash_deinit (td_sha, &concat[16]); @@ -94,8 +96,9 @@ MHD_gtls_tls_sign_hdata (MHD_gtls_session_t session, if (ver == MHD_GNUTLS_PROTOCOL_SSL3) MHD_gnutls_mac_deinit_ssl3_handshake (td_md5, concat, - session->security_parameters. - master_secret, TLS_MASTER_SIZE); + session-> + security_parameters.master_secret, + TLS_MASTER_SIZE); else MHD_gnutls_hash_deinit (td_md5, concat); @@ -122,7 +125,8 @@ int MHD_gtls_tls_sign_params (MHD_gtls_session_t session, MHD_gnutls_cert * cert, MHD_gnutls_privkey * pkey, - MHD_gnutls_datum_t * params, MHD_gnutls_datum_t * signature) + MHD_gnutls_datum_t * params, + MHD_gnutls_datum_t * signature) { MHD_gnutls_datum_t dconcat; int ret; @@ -207,7 +211,8 @@ int MHD_gtls_sign (enum MHD_GNUTLS_PublicKeyAlgorithm algo, mpi_t * params, int params_size, - const MHD_gnutls_datum_t * data, MHD_gnutls_datum_t * signature) + const MHD_gnutls_datum_t * data, + MHD_gnutls_datum_t * signature) { int ret; @@ -239,10 +244,10 @@ MHD_gtls_sign (enum MHD_GNUTLS_PublicKeyAlgorithm algo, */ static int MHD__gnutls_tls_sign (MHD_gtls_session_t session, - MHD_gnutls_cert * cert, - MHD_gnutls_privkey * pkey, - const MHD_gnutls_datum_t * hash_concat, - MHD_gnutls_datum_t * signature) + MHD_gnutls_cert * cert, + MHD_gnutls_privkey * pkey, + const MHD_gnutls_datum_t * hash_concat, + MHD_gnutls_datum_t * signature) { /* If our certificate supports signing @@ -263,8 +268,8 @@ MHD__gnutls_tls_sign (MHD_gtls_session_t session, return GNUTLS_E_INSUFFICIENT_CREDENTIALS; return (*session->internals.sign_func) (session, - session->internals. - sign_func_userdata, + session-> + internals.sign_func_userdata, cert->cert_type, &cert->raw, hash_concat, signature); } @@ -275,13 +280,13 @@ MHD__gnutls_tls_sign (MHD_gtls_session_t session, static int MHD__gnutls_verify_sig (MHD_gnutls_cert * cert, - const MHD_gnutls_datum_t * hash_concat, - MHD_gnutls_datum_t * signature, size_t sha1pos) + const MHD_gnutls_datum_t * hash_concat, + MHD_gnutls_datum_t * signature, size_t sha1pos) { int ret; MHD_gnutls_datum_t vdata; - if ( (cert == NULL) || (cert->version == 0) ) + if ((cert == NULL) || (cert->version == 0)) { /* this is the only way to check * if it is initialized */ @@ -328,7 +333,8 @@ MHD__gnutls_verify_sig (MHD_gnutls_cert * cert, */ int MHD_gtls_verify_sig_hdata (MHD_gtls_session_t session, - MHD_gnutls_cert * cert, MHD_gnutls_datum_t * signature) + MHD_gnutls_cert * cert, + MHD_gnutls_datum_t * signature) { int ret; opaque concat[36]; @@ -362,11 +368,13 @@ MHD_gtls_verify_sig_hdata (MHD_gtls_session_t session, } MHD_gnutls_mac_deinit_ssl3_handshake (td_md5, concat, - session->security_parameters. - master_secret, TLS_MASTER_SIZE); + session-> + security_parameters.master_secret, + TLS_MASTER_SIZE); MHD_gnutls_mac_deinit_ssl3_handshake (td_sha, &concat[16], - session->security_parameters. - master_secret, TLS_MASTER_SIZE); + session-> + security_parameters.master_secret, + TLS_MASTER_SIZE); } else { diff --git a/src/daemon/https/tls/gnutls_sig.h b/src/daemon/https/tls/gnutls_sig.h @@ -47,6 +47,7 @@ int MHD_gtls_verify_sig_params (MHD_gtls_session_t session, int MHD_gtls_sign (enum MHD_GNUTLS_PublicKeyAlgorithm algo, mpi_t * params, int params_size, - const MHD_gnutls_datum_t * data, MHD_gnutls_datum_t * signature); + const MHD_gnutls_datum_t * data, + MHD_gnutls_datum_t * signature); #endif diff --git a/src/daemon/https/tls/gnutls_state.c b/src/daemon/https/tls/gnutls_state.c @@ -44,7 +44,7 @@ void MHD__gnutls_session_cert_type_set (MHD_gtls_session_t session, - enum MHD_GNUTLS_CertificateType ct) + enum MHD_GNUTLS_CertificateType ct) { session->security_parameters.cert_type = ct; } @@ -236,7 +236,7 @@ MHD_gtls_handshake_internal_state_clear (MHD_gtls_session_t session) /* TODO rm redundent pointer ref */ int MHD__gnutls_init (MHD_gtls_session_t * session, - MHD_gnutls_connection_end_t con_end) + MHD_gnutls_connection_end_t con_end) { *session = MHD_gnutls_calloc (1, sizeof (struct MHD_gtls_session_int)); if (*session == NULL) @@ -286,10 +286,10 @@ MHD__gnutls_init (MHD_gtls_session_t * session, MHD__gnutls_dh_set_prime_bits ((*session), MIN_DH_BITS); - MHD__gnutls_transport_set_lowat ((*session), DEFAULT_LOWAT); /* the default for tcp */ + MHD__gnutls_transport_set_lowat ((*session), DEFAULT_LOWAT); /* the default for tcp */ MHD__gnutls_handshake_set_max_packet_length ((*session), - MAX_HANDSHAKE_PACKET_SIZE); + MAX_HANDSHAKE_PACKET_SIZE); /* Allocate a minimum size for recv_data * This is allocated in order to avoid small messages, making @@ -612,7 +612,7 @@ MHD_gtls_dh_set_group (MHD_gtls_session_t session, mpi_t gen, mpi_t prime) **/ void MHD__gnutls_certificate_send_x509_rdn_sequence (MHD_gtls_session_t session, - int status) + int status) { session->internals.ignore_rdn_sequence = status; } @@ -630,7 +630,8 @@ MHD__gnutls_certificate_send_x509_rdn_sequence (MHD_gtls_session_t session, -*/ void MHD__gnutls_record_set_default_version (MHD_gtls_session_t session, - unsigned char major, unsigned char minor) + unsigned char major, + unsigned char minor) { session->internals.default_record_version[0] = major; session->internals.default_record_version[1] = minor; @@ -661,9 +662,9 @@ MHD_gtls_handshake_set_private_extensions (MHD_gtls_session_t session, inline static int MHD__gnutls_cal_PRF_A (enum MHD_GNUTLS_HashAlgorithm algorithm, - const void *secret, - int secret_size, - const void *seed, int seed_size, void *result) + const void *secret, + int secret_size, + const void *seed, int seed_size, void *result) { mac_hd_t td1; @@ -687,10 +688,10 @@ MHD__gnutls_cal_PRF_A (enum MHD_GNUTLS_HashAlgorithm algorithm, */ static int MHD__gnutls_P_hash (enum MHD_GNUTLS_HashAlgorithm algorithm, - const opaque * secret, - int secret_size, - const opaque * seed, - int seed_size, int total_bytes, opaque * ret) + const opaque * secret, + int secret_size, + const opaque * seed, + int seed_size, int total_bytes, opaque * ret) { mac_hd_t td2; @@ -730,8 +731,9 @@ MHD__gnutls_P_hash (enum MHD_GNUTLS_HashAlgorithm algorithm, } /* here we calculate A(i+1) */ - if ((result = MHD__gnutls_cal_PRF_A (algorithm, secret, secret_size, Atmp, - A_size, Atmp)) < 0) + if ((result = + MHD__gnutls_cal_PRF_A (algorithm, secret, secret_size, Atmp, + A_size, Atmp)) < 0) { MHD_gnutls_assert (); MHD_gnutls_MHD_hmac_deinit (td2, final); @@ -816,7 +818,7 @@ MHD_gtls_PRF (MHD_gtls_session_t session, { result = MHD__gnutls_P_hash (MHD_GNUTLS_MAC_SHA1, secret, secret_size, s_seed, - s_seed_size, total_bytes, ret); + s_seed_size, total_bytes, ret); if (result < 0) { MHD_gnutls_assert (); @@ -837,7 +839,7 @@ MHD_gtls_PRF (MHD_gtls_session_t session, result = MHD__gnutls_P_hash (MHD_GNUTLS_MAC_MD5, s1, l_s, s_seed, s_seed_size, - total_bytes, o1); + total_bytes, o1); if (result < 0) { MHD_gnutls_assert (); @@ -846,7 +848,7 @@ MHD_gtls_PRF (MHD_gtls_session_t session, result = MHD__gnutls_P_hash (MHD_GNUTLS_MAC_SHA1, s2, l_s, s_seed, s_seed_size, - total_bytes, o2); + total_bytes, o2); if (result < 0) { MHD_gnutls_assert (); @@ -893,10 +895,10 @@ MHD_gtls_PRF (MHD_gtls_session_t session, **/ int MHD__gnutls_prf_raw (MHD_gtls_session_t session, - size_t label_size, - const char *label, - size_t seed_size, const char *seed, size_t outsize, - char *out) + size_t label_size, + const char *label, + size_t seed_size, const char *seed, size_t outsize, + char *out) { int ret; @@ -938,11 +940,11 @@ MHD__gnutls_prf_raw (MHD_gtls_session_t session, **/ int MHD__gnutls_prf (MHD_gtls_session_t session, - size_t label_size, - const char *label, - int server_random_first, - size_t extra_size, const char *extra, size_t outsize, - char *out) + size_t label_size, + const char *label, + int server_random_first, + size_t extra_size, const char *extra, size_t outsize, + char *out) { int ret; opaque *seed; @@ -1050,8 +1052,8 @@ MHD_gtls_session_is_resumed (MHD_gtls_session_t session) && session->security_parameters.session_id_size == session->internals.resumed_security_parameters.session_id_size && memcmp (session->security_parameters.session_id, - session->internals.resumed_security_parameters. - session_id, + session->internals. + resumed_security_parameters.session_id, session->security_parameters.session_id_size) == 0) return 1; } @@ -1078,8 +1080,8 @@ MHD_gtls_session_is_export (MHD_gtls_session_t session) enum MHD_GNUTLS_CipherAlgorithm cipher; cipher = - MHD_gtls_cipher_suite_get_cipher_algo (&session->security_parameters. - current_cipher_suite); + MHD_gtls_cipher_suite_get_cipher_algo (&session-> + security_parameters.current_cipher_suite); if (MHD_gtls_cipher_get_export_flag (cipher) != 0) return 1; @@ -1151,7 +1153,7 @@ MHD__gnutls_record_get_direction (MHD_gtls_session_t session) -*/ void MHD__gnutls_rsa_pms_set_version (MHD_gtls_session_t session, - unsigned char major, unsigned char minor) + unsigned char major, unsigned char minor) { session->internals.rsa_pms_version[0] = major; session->internals.rsa_pms_version[1] = minor; @@ -1181,9 +1183,9 @@ MHD__gnutls_rsa_pms_set_version (MHD_gtls_session_t session, **/ void MHD__gnutls_handshake_set_post_client_hello_function (MHD_gtls_session_t - session, - MHD_gnutls_handshake_post_client_hello_func - func) + session, + MHD_gnutls_handshake_post_client_hello_func + func) { session->internals.user_hello_func = func; } diff --git a/src/daemon/https/tls/gnutls_state.h b/src/daemon/https/tls/gnutls_state.h @@ -28,11 +28,11 @@ #include <gnutls_int.h> void MHD__gnutls_session_cert_type_set (MHD_gtls_session_t session, - enum MHD_GNUTLS_CertificateType); + enum MHD_GNUTLS_CertificateType); enum MHD_GNUTLS_KeyExchangeAlgorithm MHD_gnutls_kx_get (MHD_gtls_session_t - session); + session); enum MHD_GNUTLS_CipherAlgorithm MHD_gnutls_cipher_get (MHD_gtls_session_t - session); + session); enum MHD_GNUTLS_CertificateType MHD_gnutls_certificate_type_get (MHD_gtls_session_t); @@ -72,6 +72,6 @@ int MHD_gtls_PRF (MHD_gtls_session_t session, int total_bytes, void *ret); int MHD__gnutls_init (MHD_gtls_session_t * session, - MHD_gnutls_connection_end_t con_end); + MHD_gnutls_connection_end_t con_end); #define DEFAULT_CERT_TYPE MHD_GNUTLS_CRT_X509 diff --git a/src/daemon/https/tls/gnutls_str.h b/src/daemon/https/tls/gnutls_str.h @@ -43,7 +43,8 @@ typedef struct } MHD_gtls_string; void MHD_gtls_string_init (MHD_gtls_string *, MHD_gnutls_alloc_function, - MHD_gnutls_realloc_function, MHD_gnutls_free_function); + MHD_gnutls_realloc_function, + MHD_gnutls_free_function); void MHD_gtls_string_clear (MHD_gtls_string *); /* Beware, do not clear the string, after calling this diff --git a/src/daemon/https/tls/gnutls_supplemental.c b/src/daemon/https/tls/gnutls_supplemental.c @@ -68,7 +68,8 @@ MHD_gnutls_supplemental_entry MHD__gnutls_supplemental[] = { }; const char * -MHD_gtls_supplemental_get_name (MHD_gnutls_supplemental_data_format_type_t type) +MHD_gtls_supplemental_get_name (MHD_gnutls_supplemental_data_format_type_t + type) { MHD_gnutls_supplemental_entry *p; @@ -92,7 +93,8 @@ get_supp_func_recv (MHD_gnutls_supplemental_data_format_type_t type) } int -MHD__gnutls_gen_supplemental (MHD_gtls_session_t session, MHD_gtls_buffer * buf) +MHD__gnutls_gen_supplemental (MHD_gtls_session_t session, + MHD_gtls_buffer * buf) { MHD_gnutls_supplemental_entry *p; int ret; @@ -143,14 +145,14 @@ MHD__gnutls_gen_supplemental (MHD_gtls_session_t session, MHD_gtls_buffer * buf) buf->data[2] = (buf->length - 3) & 0xFF; MHD__gnutls_debug_log ("EXT[%x]: Sending %d bytes of supplemental data\n", - session, buf->length); + session, buf->length); return buf->length; } int MHD__gnutls_parse_supplemental (MHD_gtls_session_t session, - const uint8_t * data, int datalen) + const uint8_t * data, int datalen) { const opaque *p = data; ssize_t dsize = datalen; @@ -180,8 +182,9 @@ MHD__gnutls_parse_supplemental (MHD_gtls_session_t session, supp_data_length = MHD_gtls_read_uint16 (p); p += 2; - MHD__gnutls_debug_log ("EXT[%x]: Got supplemental type=%02x length=%d\n", - session, supp_data_type, supp_data_length); + MHD__gnutls_debug_log + ("EXT[%x]: Got supplemental type=%02x length=%d\n", session, + supp_data_type, supp_data_length); recv_func = get_supp_func_recv (supp_data_type); if (recv_func) diff --git a/src/daemon/https/tls/gnutls_supplemental.h b/src/daemon/https/tls/gnutls_supplemental.h @@ -25,6 +25,6 @@ #include <gnutls_int.h> int MHD__gnutls_parse_supplemental (MHD_gtls_session_t session, - const uint8_t * data, int data_size); + const uint8_t * data, int data_size); int MHD__gnutls_gen_supplemental (MHD_gtls_session_t session, - MHD_gtls_buffer * buf); + MHD_gtls_buffer * buf); diff --git a/src/daemon/https/tls/gnutls_ui.c b/src/daemon/https/tls/gnutls_ui.c @@ -74,7 +74,8 @@ MHD__gnutls_dh_set_prime_bits (MHD_gtls_session_t session, unsigned int bits) **/ int MHD__gnutls_dh_get_group (MHD_gtls_session_t session, - MHD_gnutls_datum_t * raw_gen, MHD_gnutls_datum_t * raw_prime) + MHD_gnutls_datum_t * raw_gen, + MHD_gnutls_datum_t * raw_prime) { MHD_gtls_dh_info_st *dh; int ret; @@ -107,7 +108,8 @@ MHD__gnutls_dh_get_group (MHD_gtls_session_t session, return ret; } - ret = MHD__gnutls_set_datum (raw_gen, dh->generator.data, dh->generator.size); + ret = + MHD__gnutls_set_datum (raw_gen, dh->generator.data, dh->generator.size); if (ret < 0) { MHD_gnutls_assert (); @@ -132,7 +134,7 @@ MHD__gnutls_dh_get_group (MHD_gtls_session_t session, **/ int MHD__gnutls_dh_get_pubkey (MHD_gtls_session_t session, - MHD_gnutls_datum_t * raw_key) + MHD_gnutls_datum_t * raw_key) { MHD_gtls_dh_info_st *dh; mhd_anon_auth_info_t anon_info; @@ -172,7 +174,7 @@ MHD__gnutls_dh_get_pubkey (MHD_gtls_session_t session, } return MHD__gnutls_set_datum (raw_key, dh->public_key.data, - dh->public_key.size); + dh->public_key.size); } /** @@ -203,7 +205,7 @@ MHD_gtls_rsa_export_get_pubkey (MHD_gtls_session_t session, return GNUTLS_E_INTERNAL_ERROR; ret = MHD__gnutls_set_datum (modulus, info->rsa_export.modulus.data, - info->rsa_export.modulus.size); + info->rsa_export.modulus.size); if (ret < 0) { MHD_gnutls_assert (); @@ -211,7 +213,7 @@ MHD_gtls_rsa_export_get_pubkey (MHD_gtls_session_t session, } ret = MHD__gnutls_set_datum (exponent, info->rsa_export.exponent.data, - info->rsa_export.exponent.size); + info->rsa_export.exponent.size); if (ret < 0) { MHD_gnutls_assert (); @@ -491,8 +493,8 @@ MHD_gtls_certificate_client_get_request_status (MHD_gtls_session_t session) **/ int MHD__gnutls_fingerprint (enum MHD_GNUTLS_HashAlgorithm algo, - const MHD_gnutls_datum_t * data, - void *result, size_t * result_size) + const MHD_gnutls_datum_t * data, + void *result, size_t * result_size) { GNUTLS_HASH_HANDLE td; int hash_len = MHD_gnutls_hash_get_algo_len (HASH2MAC (algo)); @@ -533,7 +535,7 @@ MHD__gnutls_fingerprint (enum MHD_GNUTLS_HashAlgorithm algo, **/ void MHD__gnutls_certificate_set_dh_params (MHD_gtls_cert_credentials_t res, - MHD_gtls_dh_params_t dh_params) + MHD_gtls_dh_params_t dh_params) { res->dh_params = dh_params; } @@ -550,7 +552,7 @@ MHD__gnutls_certificate_set_dh_params (MHD_gtls_cert_credentials_t res, **/ void MHD_gnutls_certificate_set_params_function (MHD_gtls_cert_credentials_t res, - MHD_gnutls_params_function * func) + MHD_gnutls_params_function * func) { res->params_func = func; } @@ -567,7 +569,7 @@ MHD_gnutls_certificate_set_params_function (MHD_gtls_cert_credentials_t res, **/ void MHD__gnutls_certificate_set_verify_flags (MHD_gtls_cert_credentials_t - res, unsigned int flags) + res, unsigned int flags) { res->verify_flags = flags; } @@ -585,9 +587,9 @@ MHD__gnutls_certificate_set_verify_flags (MHD_gtls_cert_credentials_t **/ void MHD__gnutls_certificate_set_verify_limits (MHD_gtls_cert_credentials_t - res, - unsigned int max_bits, - unsigned int max_depth) + res, + unsigned int max_bits, + unsigned int max_depth) { res->verify_depth = max_depth; res->verify_bits = max_bits; @@ -605,9 +607,9 @@ MHD__gnutls_certificate_set_verify_limits (MHD_gtls_cert_credentials_t **/ void MHD__gnutls_certificate_set_rsa_export_params (MHD_gtls_cert_credentials_t - res, - MHD_gtls_rsa_params_t - rsa_params) + res, + MHD_gtls_rsa_params_t + rsa_params) { res->rsa_params = rsa_params; } @@ -624,7 +626,7 @@ MHD__gnutls_certificate_set_rsa_export_params (MHD_gtls_cert_credentials_t **/ void MHD_gnutls_anon_set_params_function (MHD_gtls_anon_server_credentials_t res, - MHD_gnutls_params_function * func) + MHD_gnutls_params_function * func) { res->params_func = func; } diff --git a/src/daemon/https/tls/gnutls_x509.c b/src/daemon/https/tls/gnutls_x509.c @@ -103,7 +103,7 @@ check_bits (MHD_gnutls_x509_crt_t crt, unsigned int max_bits) -*/ int MHD__gnutls_x509_cert_verify_peers (MHD_gtls_session_t session, - unsigned int *status) + unsigned int *status) { cert_auth_info_t info; MHD_gtls_cert_credentials_t cred; @@ -142,7 +142,8 @@ MHD__gnutls_x509_cert_verify_peers (MHD_gtls_session_t session, peer_certificate_list_size = info->ncerts; peer_certificate_list = MHD_gnutls_calloc (1, - peer_certificate_list_size * sizeof (MHD_gnutls_x509_crt_t)); + peer_certificate_list_size * + sizeof (MHD_gnutls_x509_crt_t)); if (peer_certificate_list == NULL) { MHD_gnutls_assert (); @@ -161,8 +162,8 @@ MHD__gnutls_x509_cert_verify_peers (MHD_gtls_session_t session, ret = MHD_gnutls_x509_crt_import (peer_certificate_list[i], - &info->raw_certificate_list[i], - GNUTLS_X509_FMT_DER); + &info->raw_certificate_list[i], + GNUTLS_X509_FMT_DER); if (ret < 0) { MHD_gnutls_assert (); @@ -184,10 +185,10 @@ MHD__gnutls_x509_cert_verify_peers (MHD_gtls_session_t session, */ ret = MHD_gnutls_x509_crt_list_verify (peer_certificate_list, - peer_certificate_list_size, - cred->x509_ca_list, cred->x509_ncas, - cred->x509_crl_list, cred->x509_ncrls, - cred->verify_flags, status); + peer_certificate_list_size, + cred->x509_ca_list, cred->x509_ncas, + cred->x509_crl_list, cred->x509_ncrls, + cred->verify_flags, status); CLEAR_CERTS; @@ -221,13 +222,14 @@ MHD__gnutls_check_key_cert_match (MHD_gtls_cert_credentials_t res) } MHD__gnutls_x509_write_rsa_params (res->pkey[res->ncerts - 1].params, - res->pkey[res->ncerts - - 1].params_size, &kid); + res->pkey[res->ncerts - + 1].params_size, &kid); - MHD__gnutls_x509_write_rsa_params (res->cert_list[res->ncerts - 1][0].params, - res->cert_list[res->ncerts - - 1][0].params_size, &cid); + MHD__gnutls_x509_write_rsa_params (res->cert_list[res->ncerts - 1][0]. + params, + res->cert_list[res->ncerts - + 1][0].params_size, &cid); if (cid.size != kid.size) { @@ -265,7 +267,7 @@ parse_crt_mem (MHD_gnutls_cert ** cert_list, unsigned *ncerts, *cert_list = (MHD_gnutls_cert *) MHD_gtls_realloc_fast (*cert_list, - i * sizeof (MHD_gnutls_cert)); + i * sizeof (MHD_gnutls_cert)); if (*cert_list == NULL) { @@ -286,7 +288,7 @@ parse_crt_mem (MHD_gnutls_cert ** cert_list, unsigned *ncerts, } /* Reads a DER encoded certificate list from memory and stores it to - * a MHD_gnutls_cert structure. + * a MHD_gnutls_cert structure. * Returns the number of certificates parsed. */ static int @@ -355,7 +357,9 @@ parse_pem_cert_mem (MHD_gnutls_cert ** cert_list, unsigned *ncerts, do { - siz2 = MHD__gnutls_fbase64_decode (NULL, (const unsigned char*) ptr, size, &ptr2); + siz2 = + MHD__gnutls_fbase64_decode (NULL, (const unsigned char *) ptr, size, + &ptr2); if (siz2 < 0) { @@ -365,7 +369,8 @@ parse_pem_cert_mem (MHD_gnutls_cert ** cert_list, unsigned *ncerts, *cert_list = (MHD_gnutls_cert *) MHD_gtls_realloc_fast (*cert_list, - i * sizeof (MHD_gnutls_cert)); + i * + sizeof (MHD_gnutls_cert)); if (*cert_list == NULL) { @@ -382,7 +387,7 @@ parse_pem_cert_mem (MHD_gnutls_cert ** cert_list, unsigned *ncerts, MHD_gnutls_assert (); return ret; } - MHD__gnutls_free_datum (&tmp); /* free ptr2 */ + MHD__gnutls_free_datum (&tmp); /* free ptr2 */ /* now we move ptr after the pem header */ @@ -453,8 +458,8 @@ read_cert_mem (MHD_gtls_cert_credentials_t res, const void *cert, if (type == GNUTLS_X509_FMT_DER) ret = parse_der_cert_mem (&res->cert_list[res->ncerts], - &res->cert_list_length[res->ncerts], - cert, cert_size); + &res->cert_list_length[res->ncerts], + cert, cert_size); else ret = parse_pem_cert_mem (&res->cert_list[res->ncerts], @@ -473,7 +478,7 @@ read_cert_mem (MHD_gtls_cert_credentials_t res, const void *cert, int MHD__gnutls_x509_privkey_to_gkey (MHD_gnutls_privkey * dest, - MHD_gnutls_x509_privkey_t src) + MHD_gnutls_x509_privkey_t src) { int i, ret; @@ -519,8 +524,8 @@ MHD_gtls_gkey_deinit (MHD_gnutls_privkey * key) int MHD__gnutls_x509_raw_privkey_to_gkey (MHD_gnutls_privkey * privkey, - const MHD_gnutls_datum_t * raw_key, - MHD_gnutls_x509_crt_fmt_t type) + const MHD_gnutls_datum_t * raw_key, + MHD_gnutls_x509_crt_fmt_t type) { MHD_gnutls_x509_privkey_t tmpkey; int ret; @@ -539,7 +544,7 @@ MHD__gnutls_x509_raw_privkey_to_gkey (MHD_gnutls_privkey * privkey, if (ret < 0) ret = MHD_gnutls_x509_privkey_import_pkcs8 (tmpkey, raw_key, type, NULL, - GNUTLS_PKCS_PLAIN); + GNUTLS_PKCS_PLAIN); #endif if (ret < 0) @@ -591,7 +596,7 @@ read_key_mem (MHD_gtls_cert_credentials_t res, ret = MHD__gnutls_x509_raw_privkey_to_gkey (&res->pkey[res->ncerts], &tmp, - type); + type); if (ret < 0) { MHD_gnutls_assert (); @@ -636,9 +641,10 @@ read_key_mem (MHD_gtls_cert_credentials_t res, **/ int MHD__gnutls_certificate_set_x509_key_mem (MHD_gtls_cert_credentials_t - res, const MHD_gnutls_datum_t * cert, - const MHD_gnutls_datum_t * key, - MHD_gnutls_x509_crt_fmt_t type) + res, + const MHD_gnutls_datum_t * cert, + const MHD_gnutls_datum_t * key, + MHD_gnutls_x509_crt_fmt_t type) { int ret; @@ -684,7 +690,8 @@ generate_rdn_seq (MHD_gtls_cert_credentials_t res) size = 0; for (i = 0; i < res->x509_ncas; i++) { - if ((ret = MHD_gnutls_x509_crt_get_raw_dn (res->x509_ca_list[i], &tmp)) < 0) + if ((ret = + MHD_gnutls_x509_crt_get_raw_dn (res->x509_ca_list[i], &tmp)) < 0) { MHD_gnutls_assert (); return ret; @@ -708,7 +715,8 @@ generate_rdn_seq (MHD_gtls_cert_credentials_t res) for (i = 0; i < res->x509_ncas; i++) { - if ((ret = MHD_gnutls_x509_crt_get_raw_dn (res->x509_ca_list[i], &tmp)) < 0) + if ((ret = + MHD_gnutls_x509_crt_get_raw_dn (res->x509_ca_list[i], &tmp)) < 0) { MHD__gnutls_free_datum (&res->x509_rdn_sequence); MHD_gnutls_assert (); @@ -728,7 +736,7 @@ generate_rdn_seq (MHD_gtls_cert_credentials_t res) */ int MHD__gnutls_check_key_usage (const MHD_gnutls_cert * cert, - enum MHD_GNUTLS_KeyExchangeAlgorithm alg) + enum MHD_GNUTLS_KeyExchangeAlgorithm alg) { unsigned int key_usage = 0; int encipher_type; @@ -814,9 +822,9 @@ parse_pem_ca_mem (MHD_gnutls_x509_crt_t ** cert_list, unsigned *ncerts, *cert_list = (MHD_gnutls_x509_crt_t *) MHD_gtls_realloc_fast (*cert_list, - i * - sizeof - (MHD_gnutls_x509_crt_t)); + i * + sizeof + (MHD_gnutls_x509_crt_t)); if (*cert_list == NULL) { @@ -836,7 +844,7 @@ parse_pem_ca_mem (MHD_gnutls_x509_crt_t ** cert_list, unsigned *ncerts, ret = MHD_gnutls_x509_crt_import (cert_list[0][i - 1], - &tmp, GNUTLS_X509_FMT_PEM); + &tmp, GNUTLS_X509_FMT_PEM); if (ret < 0) { MHD_gnutls_assert (); @@ -892,8 +900,9 @@ parse_der_ca_mem (MHD_gnutls_x509_crt_t ** cert_list, unsigned *ncerts, *cert_list = (MHD_gnutls_x509_crt_t *) MHD_gtls_realloc_fast (*cert_list, - i * - sizeof (MHD_gnutls_x509_crt_t)); + i * + sizeof + (MHD_gnutls_x509_crt_t)); if (*cert_list == NULL) { @@ -912,7 +921,8 @@ parse_der_ca_mem (MHD_gnutls_x509_crt_t ** cert_list, unsigned *ncerts, } ret = - MHD_gnutls_x509_crt_import (cert_list[0][i - 1], &tmp, GNUTLS_X509_FMT_DER); + MHD_gnutls_x509_crt_import (cert_list[0][i - 1], &tmp, + GNUTLS_X509_FMT_DER); if (ret < 0) { MHD_gnutls_assert (); @@ -945,8 +955,9 @@ parse_der_ca_mem (MHD_gnutls_x509_crt_t ** cert_list, unsigned *ncerts, **/ int MHD__gnutls_certificate_set_x509_trust_mem (MHD_gtls_cert_credentials_t - res, const MHD_gnutls_datum_t * ca, - MHD_gnutls_x509_crt_fmt_t type) + res, + const MHD_gnutls_datum_t * ca, + MHD_gnutls_x509_crt_fmt_t type) { int ret, ret2; @@ -994,9 +1005,9 @@ parse_pem_crl_mem (MHD_gnutls_x509_crl_t ** crl_list, unsigned *ncrls, *crl_list = (MHD_gnutls_x509_crl_t *) MHD_gtls_realloc_fast (*crl_list, - i * - sizeof - (MHD_gnutls_x509_crl_t)); + i * + sizeof + (MHD_gnutls_x509_crl_t)); if (*crl_list == NULL) { @@ -1010,13 +1021,13 @@ parse_pem_crl_mem (MHD_gnutls_x509_crl_t ** crl_list, unsigned *ncrls, MHD_gnutls_assert (); return ret; } - + tmp.data = (unsigned char *) ptr; tmp.size = size; ret = MHD_gnutls_x509_crl_import (crl_list[0][i - 1], - &tmp, GNUTLS_X509_FMT_PEM); + &tmp, GNUTLS_X509_FMT_PEM); if (ret < 0) { MHD_gnutls_assert (); @@ -1062,8 +1073,9 @@ parse_der_crl_mem (MHD_gnutls_x509_crl_t ** crl_list, unsigned *ncrls, *crl_list = (MHD_gnutls_x509_crl_t *) MHD_gtls_realloc_fast (*crl_list, - i * - sizeof (MHD_gnutls_x509_crl_t)); + i * + sizeof + (MHD_gnutls_x509_crl_t)); if (*crl_list == NULL) { @@ -1082,7 +1094,8 @@ parse_der_crl_mem (MHD_gnutls_x509_crl_t ** crl_list, unsigned *ncrls, } ret = - MHD_gnutls_x509_crl_import (crl_list[0][i - 1], &tmp, GNUTLS_X509_FMT_DER); + MHD_gnutls_x509_crl_import (crl_list[0][i - 1], &tmp, + GNUTLS_X509_FMT_DER); if (ret < 0) { MHD_gnutls_assert (); @@ -1147,8 +1160,8 @@ read_crl_mem (MHD_gtls_cert_credentials_t res, const void *crl, **/ int MHD__gnutls_certificate_set_x509_crl_mem (MHD_gtls_cert_credentials_t - res, const MHD_gnutls_datum_t * CRL, - MHD_gnutls_x509_crt_fmt_t type) + res, const MHD_gnutls_datum_t * CRL, + MHD_gnutls_x509_crt_fmt_t type) { int ret; diff --git a/src/daemon/https/tls/gnutls_x509.h b/src/daemon/https/tls/gnutls_x509.h @@ -25,7 +25,7 @@ #include <libtasn1.h> int MHD__gnutls_x509_cert_verify_peers (MHD_gtls_session_t session, - unsigned int *status); + unsigned int *status); #define PEM_CERT_SEP2 "-----BEGIN X509 CERTIFICATE" #define PEM_CERT_SEP "-----BEGIN CERTIFICATE" @@ -36,13 +36,15 @@ int MHD__gnutls_x509_cert_verify_peers (MHD_gtls_session_t session, #define PEM_KEY_DSA_SEP "-----BEGIN DSA" int MHD__gnutls_check_key_usage (const MHD_gnutls_cert * cert, - enum MHD_GNUTLS_KeyExchangeAlgorithm alg); + enum MHD_GNUTLS_KeyExchangeAlgorithm alg); -int MHD__gnutls_x509_read_rsa_params (opaque * der, int dersize, mpi_t * params); -int MHD__gnutls_x509_read_dsa_pubkey (opaque * der, int dersize, mpi_t * params); +int MHD__gnutls_x509_read_rsa_params (opaque * der, int dersize, + mpi_t * params); +int MHD__gnutls_x509_read_dsa_pubkey (opaque * der, int dersize, + mpi_t * params); int MHD__gnutls_x509_raw_privkey_to_gkey (MHD_gnutls_privkey * privkey, - const MHD_gnutls_datum_t * raw_key, - MHD_gnutls_x509_crt_fmt_t type); + const MHD_gnutls_datum_t * raw_key, + MHD_gnutls_x509_crt_fmt_t type); int MHD__gnutls_x509_privkey_to_gkey (MHD_gnutls_privkey * privkey, - MHD_gnutls_x509_privkey_t); + MHD_gnutls_x509_privkey_t); diff --git a/src/daemon/https/tls/x509_b64.c b/src/daemon/https/tls/x509_b64.c @@ -154,7 +154,7 @@ decode (uint8_t * result, const opaque * data) */ int MHD__gnutls_fbase64_encode (const char *msg, const uint8_t * data, - int data_size, uint8_t ** result) + int data_size, uint8_t ** result) { int i, ret, tmp, j; char tmpres[4]; @@ -173,16 +173,16 @@ MHD__gnutls_fbase64_encode (const char *msg, const uint8_t * data, memset (bottom, 0, sizeof (bottom)); memset (top, 0, sizeof (top)); - strcat ((char*) top, "-----BEGIN "); /* Flawfinder: ignore */ - strcat ((char*)top, msg); /* Flawfinder: ignore */ - strcat ((char*)top, "-----"); /* Flawfinder: ignore */ + strcat ((char *) top, "-----BEGIN "); /* Flawfinder: ignore */ + strcat ((char *) top, msg); /* Flawfinder: ignore */ + strcat ((char *) top, "-----"); /* Flawfinder: ignore */ - strcat ((char*)bottom, "\n-----END "); /* Flawfinder: ignore */ - strcat ((char*)bottom, msg); /* Flawfinder: ignore */ - strcat ((char*)bottom, "-----\n"); /* Flawfinder: ignore */ + strcat ((char *) bottom, "\n-----END "); /* Flawfinder: ignore */ + strcat ((char *) bottom, msg); /* Flawfinder: ignore */ + strcat ((char *) bottom, "-----\n"); /* Flawfinder: ignore */ - top_len = strlen ((char*)top); - bottom_len = strlen ((char*)bottom); + top_len = strlen ((char *) top); + bottom_len = strlen ((char *) bottom); ret = B64FSIZE (msglen, data_size); @@ -197,7 +197,7 @@ MHD__gnutls_fbase64_encode (const char *msg, const uint8_t * data, INCR (bytes, top_len); pos = top_len; - strcpy ((char*)*result,(char*) top); /* Flawfinder: ignore */ + strcpy ((char *) *result, (char *) top); /* Flawfinder: ignore */ for (i = j = 0; i < data_size; i += 3, j += 4) { @@ -260,7 +260,7 @@ MHD__gnutls_fbase64_encode (const char *msg, const uint8_t * data, */ int MHD__gnutls_base64_decode (const uint8_t * data, size_t data_size, - uint8_t ** result) + uint8_t ** result) { unsigned int i, j; int ret, tmp, est; @@ -318,7 +318,7 @@ cpydata (const uint8_t * data, int data_size, uint8_t ** result) #define ENDSTR2 "-----\r" int MHD__gnutls_fbase64_decode (const char *header, const opaque * data, - size_t data_size, uint8_t ** result) + size_t data_size, uint8_t ** result) { int ret; static const char top[] = "-----BEGIN "; @@ -411,4 +411,3 @@ MHD__gnutls_fbase64_decode (const char *header, const opaque * data, return ret; } - diff --git a/src/daemon/https/tls/x509_b64.h b/src/daemon/https/tls/x509_b64.h @@ -23,11 +23,11 @@ */ int MHD__gnutls_fbase64_encode (const char *msg, const uint8_t * data, - int data_size, uint8_t ** result); + int data_size, uint8_t ** result); int MHD__gnutls_base64_decode (const uint8_t * data, size_t data_size, - uint8_t ** result); + uint8_t ** result); int MHD__gnutls_fbase64_decode (const char *header, const uint8_t * data, - size_t data_size, uint8_t ** result); + size_t data_size, uint8_t ** result); #define B64SIZE( data_size) ((data_size%3==0)?((data_size*4)/3):(4+((data_size/3)*4))) diff --git a/src/daemon/https/x509/common.c b/src/daemon/https/x509/common.c @@ -258,8 +258,9 @@ MHD__gnutls_x509_oid2ldap_string (const char *oid) */ int MHD__gnutls_x509_oid_data2string (const char *oid, - void *value, - int value_size, char *res, size_t * res_size) + void *value, + int value_size, char *res, + size_t * res_size) { char str[MAX_STRING_LEN], tmpname[128]; const char *ANAME = NULL; @@ -292,17 +293,19 @@ MHD__gnutls_x509_oid_data2string (const char *oid, MHD_gtls_str_cat (str, sizeof (str), ANAME); if ((result = MHD__asn1_create_element (MHD__gnutls_get_pkix (), str, - &tmpasn)) != ASN1_SUCCESS) + &tmpasn)) != ASN1_SUCCESS) { MHD_gnutls_assert (); return MHD_gtls_asn2err (result); } - if ((result = MHD__asn1_der_decoding (&tmpasn, value, value_size, MHD__asn1_err)) - != ASN1_SUCCESS) + if ((result = + MHD__asn1_der_decoding (&tmpasn, value, value_size, + MHD__asn1_err)) != ASN1_SUCCESS) { MHD_gnutls_assert (); - MHD__gnutls_x509_log ("MHD__asn1_der_decoding: %s:%s\n", str, MHD__asn1_err); + MHD__gnutls_x509_log ("MHD__asn1_der_decoding: %s:%s\n", str, + MHD__asn1_err); MHD__asn1_delete_structure (&tmpasn); return MHD_gtls_asn2err (result); } @@ -381,7 +384,9 @@ MHD__gnutls_x509_oid_data2string (const char *oid, } else { - result = MHD__gnutls_x509_data2hex ((const unsigned char*) str, len, (unsigned char*) res, res_size); + result = + MHD__gnutls_x509_data2hex ((const unsigned char *) str, len, + (unsigned char *) res, res_size); if (result < 0) { MHD_gnutls_assert (); @@ -400,7 +405,8 @@ MHD__gnutls_x509_oid_data2string (const char *oid, */ int MHD__gnutls_x509_data2hex (const opaque * data, - size_t data_size, opaque * out, size_t * sizeof_out) + size_t data_size, opaque * out, + size_t * sizeof_out) { char *res; char escaped[MAX_STRING_LEN]; @@ -425,8 +431,8 @@ MHD__gnutls_x509_data2hex (const opaque * data, if (out) { - strcpy ((char*) out, "#"); - strcat ((char*) out, res); + strcpy ((char *) out, "#"); + strcat ((char *) out, res); } return 0; @@ -726,10 +732,10 @@ MHD__gnutls_x509_san_find_type (char *str_type) */ int MHD__gnutls_x509_export_int (ASN1_TYPE MHD__asn1_data, - MHD_gnutls_x509_crt_fmt_t format, - char *pem_header, - unsigned char *output_data, - size_t * output_data_size) + MHD_gnutls_x509_crt_fmt_t format, + char *pem_header, + unsigned char *output_data, + size_t * output_data_size) { int result, len; @@ -741,8 +747,9 @@ MHD__gnutls_x509_export_int (ASN1_TYPE MHD__asn1_data, len = *output_data_size; - if ((result = MHD__asn1_der_coding (MHD__asn1_data, "", output_data, &len, - NULL)) != ASN1_SUCCESS) + if ((result = + MHD__asn1_der_coding (MHD__asn1_data, "", output_data, &len, + NULL)) != ASN1_SUCCESS) { *output_data_size = len; if (result == ASN1_MEM_ERROR) @@ -768,7 +775,8 @@ MHD__gnutls_x509_export_int (ASN1_TYPE MHD__asn1_data, return result; } - result = MHD__gnutls_fbase64_encode (pem_header, tmp.data, tmp.size, &out); + result = + MHD__gnutls_fbase64_encode (pem_header, tmp.data, tmp.size, &out); MHD__gnutls_free_datum (&tmp); @@ -815,9 +823,9 @@ MHD__gnutls_x509_export_int (ASN1_TYPE MHD__asn1_data, */ int MHD__gnutls_x509_decode_octet_string (const char *string_type, - const opaque * der, - size_t der_size, - opaque * output, size_t * output_size) + const opaque * der, + size_t der_size, + opaque * output, size_t * output_size) { ASN1_TYPE c2 = ASN1_TYPE_EMPTY; int result, tmp_output_size; @@ -833,7 +841,7 @@ MHD__gnutls_x509_decode_octet_string (const char *string_type, if ((result = MHD__asn1_create_element (MHD__gnutls_get_pkix (), strname, - &c2)) != ASN1_SUCCESS) + &c2)) != ASN1_SUCCESS) { MHD_gnutls_assert (); result = MHD_gtls_asn2err (result); @@ -875,7 +883,8 @@ cleanup:if (c2) */ int MHD__gnutls_x509_read_value (ASN1_TYPE c, - const char *root, MHD_gnutls_datum_t * ret, int flags) + const char *root, MHD_gnutls_datum_t * ret, + int flags) { int len = 0, result; size_t slen; @@ -917,7 +926,8 @@ MHD__gnutls_x509_read_value (ASN1_TYPE c, if (flags == 1) { slen = len; - result = MHD__gnutls_x509_decode_octet_string (NULL, tmp, slen, tmp, &slen); + result = + MHD__gnutls_x509_decode_octet_string (NULL, tmp, slen, tmp, &slen); if (result < 0) { MHD_gnutls_assert (); @@ -942,7 +952,8 @@ cleanup:MHD_gnutls_free (tmp); */ int MHD__gnutls_x509_der_encode (ASN1_TYPE src, - const char *src_name, MHD_gnutls_datum_t * res, int str) + const char *src_name, MHD_gnutls_datum_t * res, + int str) { int size, result; int asize; @@ -984,8 +995,9 @@ MHD__gnutls_x509_der_encode (ASN1_TYPE src, if (str) { if ((result = - MHD__asn1_create_element (MHD__gnutls_get_pkix (), "PKIX1.pkcs-7-Data", - &c2)) != ASN1_SUCCESS) + MHD__asn1_create_element (MHD__gnutls_get_pkix (), + "PKIX1.pkcs-7-Data", + &c2)) != ASN1_SUCCESS) { MHD_gnutls_assert (); result = MHD_gtls_asn2err (result); @@ -1030,9 +1042,9 @@ cleanup:MHD_gnutls_free (data); */ int MHD__gnutls_x509_der_encode_and_copy (ASN1_TYPE src, - const char *src_name, - ASN1_TYPE dest, - const char *dest_name, int str) + const char *src_name, + ASN1_TYPE dest, + const char *dest_name, int str) { int result; MHD_gnutls_datum_t encoded; @@ -1047,7 +1059,8 @@ MHD__gnutls_x509_der_encode_and_copy (ASN1_TYPE src, /* Write the data. */ - result = MHD__asn1_write_value (dest, dest_name, encoded.data, encoded.size); + result = + MHD__asn1_write_value (dest, dest_name, encoded.data, encoded.size); MHD__gnutls_free_datum (&encoded); @@ -1065,8 +1078,8 @@ MHD__gnutls_x509_der_encode_and_copy (ASN1_TYPE src, */ int MHD__gnutls_x509_write_value (ASN1_TYPE c, - const char *root, - const MHD_gnutls_datum_t * data, int str) + const char *root, + const MHD_gnutls_datum_t * data, int str) { int result; int asize; @@ -1088,8 +1101,9 @@ MHD__gnutls_x509_write_value (ASN1_TYPE c, /* Convert it to OCTET STRING */ if ((result = - MHD__asn1_create_element (MHD__gnutls_get_pkix (), "PKIX1.pkcs-7-Data", - &c2)) != ASN1_SUCCESS) + MHD__asn1_create_element (MHD__gnutls_get_pkix (), + "PKIX1.pkcs-7-Data", + &c2)) != ASN1_SUCCESS) { MHD_gnutls_assert (); result = MHD_gtls_asn2err (result); @@ -1144,10 +1158,11 @@ cleanup:if (val.data != data->data) */ int MHD__gnutls_x509_encode_and_copy_PKI_params (ASN1_TYPE dst, - const char *dst_name, - enum MHD_GNUTLS_PublicKeyAlgorithm - pk_algorithm, - mpi_t * params, int params_size) + const char *dst_name, + enum + MHD_GNUTLS_PublicKeyAlgorithm + pk_algorithm, mpi_t * params, + int params_size) { const char *pk; MHD_gnutls_datum_t der = { NULL, @@ -1219,7 +1234,7 @@ MHD__gnutls_x509_encode_and_copy_PKI_params (ASN1_TYPE dst, */ int MHD__gnutls_x509_get_pk_algorithm (ASN1_TYPE src, - const char *src_name, unsigned int *bits) + const char *src_name, unsigned int *bits) { int result; opaque *str = NULL; @@ -1295,7 +1310,8 @@ MHD__gnutls_x509_get_pk_algorithm (ASN1_TYPE src, { case MHD_GNUTLS_PK_RSA: { - if ((result = MHD__gnutls_x509_read_rsa_params (str, len, params)) < 0) + if ((result = + MHD__gnutls_x509_read_rsa_params (str, len, params)) < 0) { MHD_gnutls_assert (); return result; @@ -1321,8 +1337,8 @@ MHD__gnutls_x509_get_pk_algorithm (ASN1_TYPE src, */ int MHD__gnutls_x509_get_signed_data (ASN1_TYPE src, - const char *src_name, - MHD_gnutls_datum_t * signed_data) + const char *src_name, + MHD_gnutls_datum_t * signed_data) { MHD_gnutls_datum_t der; int start, end, result; @@ -1337,7 +1353,7 @@ MHD__gnutls_x509_get_signed_data (ASN1_TYPE src, /* Get the signed data */ result = MHD__asn1_der_decoding_startEnd (src, der.data, der.size, src_name, - &start, &end); + &start, &end); if (result != ASN1_SUCCESS) { result = MHD_gtls_asn2err (result); @@ -1345,7 +1361,8 @@ MHD__gnutls_x509_get_signed_data (ASN1_TYPE src, goto cleanup; } - result = MHD__gnutls_set_datum (signed_data, &der.data[start], end - start + 1); + result = + MHD__gnutls_set_datum (signed_data, &der.data[start], end - start + 1); if (result < 0) { @@ -1365,7 +1382,8 @@ cleanup:MHD__gnutls_free_datum (&der); */ int MHD__gnutls_x509_get_signature (ASN1_TYPE src, - const char *src_name, MHD_gnutls_datum_t * signature) + const char *src_name, + MHD_gnutls_datum_t * signature) { int bits, result, len; diff --git a/src/daemon/https/x509/common.h b/src/daemon/https/x509/common.h @@ -59,13 +59,14 @@ #define SIG_GOST_R3410_2001_OID "1.2.643.2.2.3" int MHD__gnutls_x509_decode_octet_string (const char *string_type, - const opaque * der, size_t der_size, - opaque * output, size_t * output_size); + const opaque * der, size_t der_size, + opaque * output, + size_t * output_size); int MHD__gnutls_x509_oid_data2string (const char *OID, void *value, - int value_size, char *res, - size_t * res_size); + int value_size, char *res, + size_t * res_size); int MHD__gnutls_x509_data2hex (const opaque * data, size_t data_size, - opaque * out, size_t * sizeof_out); + opaque * out, size_t * sizeof_out); const char *MHD__gnutls_x509_oid2ldap_string (const char *OID); @@ -74,50 +75,51 @@ int MHD__gnutls_x509_oid_data_printable (const char *OID); time_t MHD__gnutls_x509_get_time (ASN1_TYPE c2, const char *when); -MHD_gnutls_x509_subject_alt_name_t MHD__gnutls_x509_san_find_type (char *str_type); +MHD_gnutls_x509_subject_alt_name_t MHD__gnutls_x509_san_find_type (char + *str_type); int MHD__gnutls_x509_der_encode_and_copy (ASN1_TYPE src, const char *src_name, - ASN1_TYPE dest, const char *dest_name, - int str); + ASN1_TYPE dest, + const char *dest_name, int str); int MHD__gnutls_x509_der_encode (ASN1_TYPE src, const char *src_name, - MHD_gnutls_datum_t * res, int str); + MHD_gnutls_datum_t * res, int str); int MHD__gnutls_x509_export_int (ASN1_TYPE MHD__asn1_data, - MHD_gnutls_x509_crt_fmt_t format, char *pem_header, - unsigned char *output_data, - size_t * output_data_size); + MHD_gnutls_x509_crt_fmt_t format, + char *pem_header, unsigned char *output_data, + size_t * output_data_size); int MHD__gnutls_x509_read_value (ASN1_TYPE c, const char *root, - MHD_gnutls_datum_t * ret, int str); + MHD_gnutls_datum_t * ret, int str); int MHD__gnutls_x509_write_value (ASN1_TYPE c, const char *root, - const MHD_gnutls_datum_t * data, int str); + const MHD_gnutls_datum_t * data, int str); int MHD__gnutls_x509_encode_and_write_attribute (const char *given_oid, - ASN1_TYPE MHD__asn1_struct, - const char *where, - const void *data, - int sizeof_data, int multi); + ASN1_TYPE MHD__asn1_struct, + const char *where, + const void *data, + int sizeof_data, int multi); int MHD__gnutls_x509_decode_and_read_attribute (ASN1_TYPE MHD__asn1_struct, - const char *where, char *oid, - int oid_size, - MHD_gnutls_datum_t * value, int multi, - int octet); + const char *where, char *oid, + int oid_size, + MHD_gnutls_datum_t * value, + int multi, int octet); int MHD__gnutls_x509_get_pk_algorithm (ASN1_TYPE src, const char *src_name, - unsigned int *bits); + unsigned int *bits); int MHD__gnutls_x509_encode_and_copy_PKI_params (ASN1_TYPE dst, - const char *dst_name, - enum - MHD_GNUTLS_PublicKeyAlgorithm - pk_algorithm, mpi_t * params, - int params_size); + const char *dst_name, + enum + MHD_GNUTLS_PublicKeyAlgorithm + pk_algorithm, mpi_t * params, + int params_size); int MHD__gnutls_asn1_copy_node (ASN1_TYPE * dst, const char *dst_name, - ASN1_TYPE src, const char *src_name); + ASN1_TYPE src, const char *src_name); int MHD__gnutls_x509_get_signed_data (ASN1_TYPE src, const char *src_name, - MHD_gnutls_datum_t * signed_data); + MHD_gnutls_datum_t * signed_data); int MHD__gnutls_x509_get_signature (ASN1_TYPE src, const char *src_name, - MHD_gnutls_datum_t * signature); + MHD_gnutls_datum_t * signature); #endif diff --git a/src/daemon/https/x509/crl.c b/src/daemon/https/x509/crl.c @@ -56,8 +56,8 @@ MHD_gnutls_x509_crl_init (MHD_gnutls_x509_crl_t * crl) if (*crl) { int result = MHD__asn1_create_element (MHD__gnutls_get_pkix (), - "PKIX1.CertificateList", - &(*crl)->crl); + "PKIX1.CertificateList", + &(*crl)->crl); if (result != ASN1_SUCCESS) { MHD_gnutls_assert (); @@ -104,8 +104,8 @@ MHD_gnutls_x509_crl_deinit (MHD_gnutls_x509_crl_t crl) **/ int MHD_gnutls_x509_crl_import (MHD_gnutls_x509_crl_t crl, - const MHD_gnutls_datum_t * data, - MHD_gnutls_x509_crt_fmt_t format) + const MHD_gnutls_datum_t * data, + MHD_gnutls_x509_crt_fmt_t format) { int result = 0, need_free = 0; MHD_gnutls_datum_t _data; @@ -125,7 +125,8 @@ MHD_gnutls_x509_crl_import (MHD_gnutls_x509_crl_t crl, { opaque *out; - result = MHD__gnutls_fbase64_decode (PEM_CRL, data->data, data->size, &out); + result = + MHD__gnutls_fbase64_decode (PEM_CRL, data->data, data->size, &out); if (result <= 0) { @@ -181,7 +182,7 @@ cleanup: **/ int MHD_gnutls_x509_crl_get_issuer_dn (const MHD_gnutls_x509_crl_t crl, char *buf, - size_t * sizeof_buf) + size_t * sizeof_buf) { if (crl == NULL) { @@ -190,8 +191,8 @@ MHD_gnutls_x509_crl_get_issuer_dn (const MHD_gnutls_x509_crl_t crl, char *buf, } return MHD__gnutls_x509_parse_dn (crl->crl, - "tbsCertList.issuer.rdnSequence", - buf, sizeof_buf); + "tbsCertList.issuer.rdnSequence", + buf, sizeof_buf); } /** @@ -221,9 +222,9 @@ MHD_gnutls_x509_crl_get_issuer_dn (const MHD_gnutls_x509_crl_t crl, char *buf, **/ int MHD_gnutls_x509_crl_get_issuer_dn_by_oid (MHD_gnutls_x509_crl_t crl, - const char *oid, int indx, - unsigned int raw_flag, void *buf, - size_t * sizeof_buf) + const char *oid, int indx, + unsigned int raw_flag, void *buf, + size_t * sizeof_buf) { if (crl == NULL) { @@ -232,8 +233,8 @@ MHD_gnutls_x509_crl_get_issuer_dn_by_oid (MHD_gnutls_x509_crl_t crl, } return MHD__gnutls_x509_parse_dn_oid (crl->crl, - "tbsCertList.issuer.rdnSequence", - oid, indx, raw_flag, buf, sizeof_buf); + "tbsCertList.issuer.rdnSequence", + oid, indx, raw_flag, buf, sizeof_buf); } /** @@ -255,7 +256,7 @@ MHD_gnutls_x509_crl_get_issuer_dn_by_oid (MHD_gnutls_x509_crl_t crl, **/ int MHD_gnutls_x509_crl_get_dn_oid (MHD_gnutls_x509_crl_t crl, - int indx, void *oid, size_t * sizeof_oid) + int indx, void *oid, size_t * sizeof_oid) { if (crl == NULL) { @@ -264,8 +265,8 @@ MHD_gnutls_x509_crl_get_dn_oid (MHD_gnutls_x509_crl_t crl, } return MHD__gnutls_x509_get_dn_oid (crl->crl, - "tbsCertList.issuer.rdnSequence", indx, - oid, sizeof_oid); + "tbsCertList.issuer.rdnSequence", indx, + oid, sizeof_oid); } @@ -297,7 +298,7 @@ MHD_gnutls_x509_crl_get_signature_algorithm (MHD_gnutls_x509_crl_t crl) result = MHD__gnutls_x509_read_value (crl->crl, "signatureAlgorithm.algorithm", - &sa, 0); + &sa, 0); if (result < 0) { @@ -324,7 +325,7 @@ MHD_gnutls_x509_crl_get_signature_algorithm (MHD_gnutls_x509_crl_t crl) **/ int MHD_gnutls_x509_crl_get_signature (MHD_gnutls_x509_crl_t crl, - char *sig, size_t * sizeof_sig) + char *sig, size_t * sizeof_sig) { int result; int bits, len; @@ -391,7 +392,7 @@ MHD_gnutls_x509_crl_get_version (MHD_gnutls_x509_crl_t crl) len = sizeof (version); if ((result = MHD__asn1_read_value (crl->crl, "tbsCertList.version", version, - &len)) != ASN1_SUCCESS) + &len)) != ASN1_SUCCESS) { MHD_gnutls_assert (); return MHD_gtls_asn2err (result); @@ -468,7 +469,7 @@ MHD_gnutls_x509_crl_get_crt_count (MHD_gnutls_x509_crl_t crl) result = MHD__asn1_number_of_elements (crl->crl, - "tbsCertList.revokedCertificates", &count); + "tbsCertList.revokedCertificates", &count); if (result != ASN1_SUCCESS) { @@ -495,8 +496,8 @@ MHD_gnutls_x509_crl_get_crt_count (MHD_gnutls_x509_crl_t crl) **/ int MHD_gnutls_x509_crl_get_crt_serial (MHD_gnutls_x509_crl_t crl, int indx, - unsigned char *serial, - size_t * serial_size, time_t * t) + unsigned char *serial, + size_t * serial_size, time_t * t) { int result, _serial_size; @@ -515,7 +516,8 @@ MHD_gnutls_x509_crl_get_crt_serial (MHD_gnutls_x509_crl_t crl, int indx, "tbsCertList.revokedCertificates.?%u.revocationDate", indx + 1); _serial_size = *serial_size; - result = MHD__asn1_read_value (crl->crl, serial_name, serial, &_serial_size); + result = + MHD__asn1_read_value (crl->crl, serial_name, serial, &_serial_size); *serial_size = _serial_size; if (result != ASN1_SUCCESS) @@ -547,7 +549,7 @@ MHD_gnutls_x509_crl_get_crt_serial (MHD_gnutls_x509_crl_t crl, int indx, -*/ int MHD__gnutls_x509_crl_get_raw_issuer_dn (MHD_gnutls_x509_crl_t crl, - MHD_gnutls_datum_t * dn) + MHD_gnutls_datum_t * dn) { ASN1_TYPE c2 = ASN1_TYPE_EMPTY; int result, len1; @@ -564,14 +566,15 @@ MHD__gnutls_x509_crl_get_raw_issuer_dn (MHD_gnutls_x509_crl_t crl, */ if ((result = MHD__asn1_create_element (MHD__gnutls_get_pkix (), "PKIX1.TBSCertList", - &c2)) != ASN1_SUCCESS) + &c2)) != ASN1_SUCCESS) { MHD_gnutls_assert (); return MHD_gtls_asn2err (result); } result = - MHD__gnutls_x509_get_signed_data (crl->crl, "tbsCertList", &crl_signed_data); + MHD__gnutls_x509_get_signed_data (crl->crl, "tbsCertList", + &crl_signed_data); if (result < 0) { MHD_gnutls_assert (); @@ -579,7 +582,8 @@ MHD__gnutls_x509_crl_get_raw_issuer_dn (MHD_gnutls_x509_crl_t crl, } result = - MHD__asn1_der_decoding (&c2, crl_signed_data.data, crl_signed_data.size, NULL); + MHD__asn1_der_decoding (&c2, crl_signed_data.data, crl_signed_data.size, + NULL); if (result != ASN1_SUCCESS) { /* couldn't decode DER */ @@ -591,8 +595,8 @@ MHD__gnutls_x509_crl_get_raw_issuer_dn (MHD_gnutls_x509_crl_t crl, result = MHD__asn1_der_decoding_startEnd (c2, crl_signed_data.data, - crl_signed_data.size, "issuer", - &start1, &end1); + crl_signed_data.size, "issuer", + &start1, &end1); if (result != ASN1_SUCCESS) { @@ -633,8 +637,8 @@ cleanup: **/ int MHD_gnutls_x509_crl_export (MHD_gnutls_x509_crl_t crl, - MHD_gnutls_x509_crt_fmt_t format, void *output_data, - size_t * output_data_size) + MHD_gnutls_x509_crt_fmt_t format, + void *output_data, size_t * output_data_size) { if (crl == NULL) { @@ -643,7 +647,7 @@ MHD_gnutls_x509_crl_export (MHD_gnutls_x509_crl_t crl, } return MHD__gnutls_x509_export_int (crl->crl, format, PEM_CRL, - output_data, output_data_size); + output_data, output_data_size); } /*- @@ -657,14 +661,16 @@ MHD_gnutls_x509_crl_export (MHD_gnutls_x509_crl_t crl, * -*/ int -MHD__gnutls_x509_crl_cpy (MHD_gnutls_x509_crl_t dest, MHD_gnutls_x509_crl_t src) +MHD__gnutls_x509_crl_cpy (MHD_gnutls_x509_crl_t dest, + MHD_gnutls_x509_crl_t src) { int ret; size_t der_size; opaque *der; MHD_gnutls_datum_t tmp; - ret = MHD_gnutls_x509_crl_export (src, GNUTLS_X509_FMT_DER, NULL, &der_size); + ret = + MHD_gnutls_x509_crl_export (src, GNUTLS_X509_FMT_DER, NULL, &der_size); if (ret != GNUTLS_E_SHORT_MEMORY_BUFFER) { MHD_gnutls_assert (); diff --git a/src/daemon/https/x509/crq.c b/src/daemon/https/x509/crq.c @@ -59,8 +59,8 @@ MHD_gnutls_x509_crq_init (MHD_gnutls_x509_crq_t * crq) if (*crq) { int result = MHD__asn1_create_element (MHD__gnutls_get_pkix (), - "PKIX1.pkcs-10-CertificationRequest", - &((*crq)->crq)); + "PKIX1.pkcs-10-CertificationRequest", + &((*crq)->crq)); if (result != ASN1_SUCCESS) { MHD_gnutls_assert (); @@ -110,8 +110,8 @@ MHD_gnutls_x509_crq_deinit (MHD_gnutls_x509_crq_t crq) **/ int MHD_gnutls_x509_crq_import (MHD_gnutls_x509_crq_t crq, - const MHD_gnutls_datum_t * data, - MHD_gnutls_x509_crt_fmt_t format) + const MHD_gnutls_datum_t * data, + MHD_gnutls_x509_crt_fmt_t format) { int result = 0, need_free = 0; MHD_gnutls_datum_t _data; @@ -132,7 +132,8 @@ MHD_gnutls_x509_crq_import (MHD_gnutls_x509_crq_t crq, opaque *out; /* Try the first header */ - result = MHD__gnutls_fbase64_decode (PEM_CRQ, data->data, data->size, &out); + result = + MHD__gnutls_fbase64_decode (PEM_CRQ, data->data, data->size, &out); if (result <= 0) /* Go for the second header */ result = @@ -189,7 +190,8 @@ cleanup: * **/ int -MHD_gnutls_x509_crq_get_dn (MHD_gnutls_x509_crq_t crq, char *buf, size_t * sizeof_buf) +MHD_gnutls_x509_crq_get_dn (MHD_gnutls_x509_crq_t crq, char *buf, + size_t * sizeof_buf) { if (crq == NULL) { @@ -198,8 +200,8 @@ MHD_gnutls_x509_crq_get_dn (MHD_gnutls_x509_crq_t crq, char *buf, size_t * sizeo } return MHD__gnutls_x509_parse_dn (crq->crq, - "certificationRequestInfo.subject.rdnSequence", - buf, sizeof_buf); + "certificationRequestInfo.subject.rdnSequence", + buf, sizeof_buf); } /** @@ -232,8 +234,8 @@ MHD_gnutls_x509_crq_get_dn (MHD_gnutls_x509_crq_t crq, char *buf, size_t * sizeo **/ int MHD_gnutls_x509_crq_get_dn_by_oid (MHD_gnutls_x509_crq_t crq, const char *oid, - int indx, unsigned int raw_flag, - void *buf, size_t * sizeof_buf) + int indx, unsigned int raw_flag, + void *buf, size_t * sizeof_buf) { if (crq == NULL) { @@ -242,8 +244,8 @@ MHD_gnutls_x509_crq_get_dn_by_oid (MHD_gnutls_x509_crq_t crq, const char *oid, } return MHD__gnutls_x509_parse_dn_oid (crq->crq, - "certificationRequestInfo.subject.rdnSequence", - oid, indx, raw_flag, buf, sizeof_buf); + "certificationRequestInfo.subject.rdnSequence", + oid, indx, raw_flag, buf, sizeof_buf); } /** @@ -265,7 +267,7 @@ MHD_gnutls_x509_crq_get_dn_by_oid (MHD_gnutls_x509_crq_t crq, const char *oid, **/ int MHD_gnutls_x509_crq_get_dn_oid (MHD_gnutls_x509_crq_t crq, - int indx, void *oid, size_t * sizeof_oid) + int indx, void *oid, size_t * sizeof_oid) { if (crq == NULL) { @@ -274,8 +276,8 @@ MHD_gnutls_x509_crq_get_dn_oid (MHD_gnutls_x509_crq_t crq, } return MHD__gnutls_x509_get_dn_oid (crq->crq, - "certificationRequestInfo.subject.rdnSequence", - indx, oid, sizeof_oid); + "certificationRequestInfo.subject.rdnSequence", + indx, oid, sizeof_oid); } /* Parses an Attribute list in the MHD__asn1_struct, and searches for the @@ -319,7 +321,8 @@ parse_attribute (ASN1_TYPE MHD__asn1_struct, snprintf (tmpbuffer1, sizeof (tmpbuffer1), "?%u", k1); len = sizeof (value) - 1; - result = MHD__asn1_read_value (MHD__asn1_struct, tmpbuffer1, value, &len); + result = + MHD__asn1_read_value (MHD__asn1_struct, tmpbuffer1, value, &len); if (result == ASN1_ELEMENT_NOT_FOUND) { @@ -362,7 +365,8 @@ parse_attribute (ASN1_TYPE MHD__asn1_struct, tmpbuffer1, indx + 1); len = sizeof (value) - 1; - result = MHD__asn1_read_value (MHD__asn1_struct, tmpbuffer3, value, &len); + result = + MHD__asn1_read_value (MHD__asn1_struct, tmpbuffer3, value, &len); if (result != ASN1_SUCCESS) { @@ -434,7 +438,7 @@ cleanup: **/ int MHD_gnutls_x509_crq_get_challenge_password (MHD_gnutls_x509_crq_t crq, - char *pass, size_t * sizeof_pass) + char *pass, size_t * sizeof_pass) { if (crq == NULL) { @@ -461,8 +465,8 @@ MHD_gnutls_x509_crq_get_challenge_password (MHD_gnutls_x509_crq_t crq, **/ int MHD_gnutls_x509_crq_set_attribute_by_oid (MHD_gnutls_x509_crq_t crq, - const char *oid, void *buf, - size_t sizeof_buf) + const char *oid, void *buf, + size_t sizeof_buf) { int result; @@ -476,7 +480,7 @@ MHD_gnutls_x509_crq_set_attribute_by_oid (MHD_gnutls_x509_crq_t crq, */ result = MHD__asn1_write_value (crq->crq, "certificationRequestInfo.attributes", - "NEW", 1); + "NEW", 1); if (result != ASN1_SUCCESS) { MHD_gnutls_assert (); @@ -485,9 +489,9 @@ MHD_gnutls_x509_crq_set_attribute_by_oid (MHD_gnutls_x509_crq_t crq, result = MHD__gnutls_x509_encode_and_write_attribute (oid, - crq->crq, - "certificationRequestInfo.attributes.?LAST", - buf, sizeof_buf, 1); + crq->crq, + "certificationRequestInfo.attributes.?LAST", + buf, sizeof_buf, 1); if (result < 0) { @@ -515,8 +519,8 @@ MHD_gnutls_x509_crq_set_attribute_by_oid (MHD_gnutls_x509_crq_t crq, **/ int MHD_gnutls_x509_crq_get_attribute_by_oid (MHD_gnutls_x509_crq_t crq, - const char *oid, int indx, void *buf, - size_t * sizeof_buf) + const char *oid, int indx, + void *buf, size_t * sizeof_buf) { if (crq == NULL) { @@ -550,8 +554,8 @@ MHD_gnutls_x509_crq_get_attribute_by_oid (MHD_gnutls_x509_crq_t crq, **/ int MHD_gnutls_x509_crq_set_dn_by_oid (MHD_gnutls_x509_crq_t crq, const char *oid, - unsigned int raw_flag, const void *data, - unsigned int sizeof_data) + unsigned int raw_flag, const void *data, + unsigned int sizeof_data) { if (sizeof_data == 0 || data == NULL || crq == NULL) { @@ -559,8 +563,8 @@ MHD_gnutls_x509_crq_set_dn_by_oid (MHD_gnutls_x509_crq_t crq, const char *oid, } return MHD__gnutls_x509_set_dn_oid (crq->crq, - "certificationRequestInfo.subject", oid, - raw_flag, data, sizeof_data); + "certificationRequestInfo.subject", oid, + raw_flag, data, sizeof_data); } /** @@ -575,7 +579,8 @@ MHD_gnutls_x509_crq_set_dn_by_oid (MHD_gnutls_x509_crq_t crq, const char *oid, * **/ int -MHD_gnutls_x509_crq_set_version (MHD_gnutls_x509_crq_t crq, unsigned int version) +MHD_gnutls_x509_crq_set_version (MHD_gnutls_x509_crq_t crq, + unsigned int version) { int result; unsigned char null = version; @@ -590,7 +595,8 @@ MHD_gnutls_x509_crq_set_version (MHD_gnutls_x509_crq_t crq, unsigned int version null--; result = - MHD__asn1_write_value (crq->crq, "certificationRequestInfo.version", &null, 1); + MHD__asn1_write_value (crq->crq, "certificationRequestInfo.version", + &null, 1); if (result != ASN1_SUCCESS) { MHD_gnutls_assert (); @@ -624,7 +630,7 @@ MHD_gnutls_x509_crq_get_version (MHD_gnutls_x509_crq_t crq) len = sizeof (version); if ((result = MHD__asn1_read_value (crq->crq, "certificationRequestInfo.version", - version, &len)) != ASN1_SUCCESS) + version, &len)) != ASN1_SUCCESS) { if (result == ASN1_ELEMENT_NOT_FOUND) @@ -648,7 +654,8 @@ MHD_gnutls_x509_crq_get_version (MHD_gnutls_x509_crq_t crq) * **/ int -MHD_gnutls_x509_crq_set_key (MHD_gnutls_x509_crq_t crq, MHD_gnutls_x509_privkey_t key) +MHD_gnutls_x509_crq_set_key (MHD_gnutls_x509_crq_t crq, + MHD_gnutls_x509_privkey_t key) { int result; @@ -659,10 +666,10 @@ MHD_gnutls_x509_crq_set_key (MHD_gnutls_x509_crq_t crq, MHD_gnutls_x509_privkey_ } result = MHD__gnutls_x509_encode_and_copy_PKI_params (crq->crq, - "certificationRequestInfo.subjectPKInfo", - key->pk_algorithm, - key->params, - key->params_size); + "certificationRequestInfo.subjectPKInfo", + key->pk_algorithm, + key->params, + key->params_size); if (result < 0) { @@ -685,7 +692,7 @@ MHD_gnutls_x509_crq_set_key (MHD_gnutls_x509_crq_t crq, MHD_gnutls_x509_privkey_ **/ int MHD_gnutls_x509_crq_set_challenge_password (MHD_gnutls_x509_crq_t crq, - const char *pass) + const char *pass) { int result; @@ -699,7 +706,7 @@ MHD_gnutls_x509_crq_set_challenge_password (MHD_gnutls_x509_crq_t crq, */ result = MHD__asn1_write_value (crq->crq, "certificationRequestInfo.attributes", - "NEW", 1); + "NEW", 1); if (result != ASN1_SUCCESS) { MHD_gnutls_assert (); @@ -708,9 +715,9 @@ MHD_gnutls_x509_crq_set_challenge_password (MHD_gnutls_x509_crq_t crq, result = MHD__gnutls_x509_encode_and_write_attribute ("1.2.840.113549.1.9.7", - crq->crq, - "certificationRequestInfo.attributes.?LAST", - pass, strlen (pass), 1); + crq->crq, + "certificationRequestInfo.attributes.?LAST", + pass, strlen (pass), 1); if (result < 0) { @@ -739,8 +746,10 @@ MHD_gnutls_x509_crq_set_challenge_password (MHD_gnutls_x509_crq_t crq, * **/ int -MHD_gnutls_x509_crq_sign2 (MHD_gnutls_x509_crq_t crq, MHD_gnutls_x509_privkey_t key, - enum MHD_GNUTLS_HashAlgorithm dig, unsigned int flags) +MHD_gnutls_x509_crq_sign2 (MHD_gnutls_x509_crq_t crq, + MHD_gnutls_x509_privkey_t key, + enum MHD_GNUTLS_HashAlgorithm dig, + unsigned int flags) { int result; MHD_gnutls_datum_t signature; @@ -755,7 +764,7 @@ MHD_gnutls_x509_crq_sign2 (MHD_gnutls_x509_crq_t crq, MHD_gnutls_x509_privkey_t */ result = MHD__gnutls_x509_sign_tbs (crq->crq, "certificationRequestInfo", - dig, key, &signature); + dig, key, &signature); if (result < 0) { @@ -767,7 +776,7 @@ MHD_gnutls_x509_crq_sign2 (MHD_gnutls_x509_crq_t crq, MHD_gnutls_x509_privkey_t */ result = MHD__asn1_write_value (crq->crq, "signature", signature.data, - signature.size * 8); + signature.size * 8); MHD__gnutls_free_datum (&signature); @@ -780,8 +789,8 @@ MHD_gnutls_x509_crq_sign2 (MHD_gnutls_x509_crq_t crq, MHD_gnutls_x509_privkey_t /* Step 3. Write the signatureAlgorithm field. */ result = MHD__gnutls_x509_write_sig_params (crq->crq, "signatureAlgorithm", - key->pk_algorithm, dig, key->params, - key->params_size); + key->pk_algorithm, dig, + key->params, key->params_size); if (result < 0) { MHD_gnutls_assert (); @@ -803,7 +812,8 @@ MHD_gnutls_x509_crq_sign2 (MHD_gnutls_x509_crq_t crq, MHD_gnutls_x509_privkey_t * **/ int -MHD_gnutls_x509_crq_sign (MHD_gnutls_x509_crq_t crq, MHD_gnutls_x509_privkey_t key) +MHD_gnutls_x509_crq_sign (MHD_gnutls_x509_crq_t crq, + MHD_gnutls_x509_privkey_t key) { return MHD_gnutls_x509_crq_sign2 (crq, key, MHD_GNUTLS_MAC_SHA1, 0); } @@ -831,8 +841,8 @@ MHD_gnutls_x509_crq_sign (MHD_gnutls_x509_crq_t crq, MHD_gnutls_x509_privkey_t k **/ int MHD_gnutls_x509_crq_export (MHD_gnutls_x509_crq_t crq, - MHD_gnutls_x509_crt_fmt_t format, void *output_data, - size_t * output_data_size) + MHD_gnutls_x509_crt_fmt_t format, + void *output_data, size_t * output_data_size) { if (crq == NULL) { @@ -841,7 +851,7 @@ MHD_gnutls_x509_crq_export (MHD_gnutls_x509_crq_t crq, } return MHD__gnutls_x509_export_int (crq->crq, format, PEM_CRQ, - output_data, output_data_size); + output_data, output_data_size); } /** @@ -862,7 +872,8 @@ MHD_gnutls_x509_crq_export (MHD_gnutls_x509_crq_t crq, * **/ int -MHD_gnutls_x509_crq_get_pk_algorithm (MHD_gnutls_x509_crq_t crq, unsigned int *bits) +MHD_gnutls_x509_crq_get_pk_algorithm (MHD_gnutls_x509_crq_t crq, + unsigned int *bits) { int result; @@ -874,8 +885,8 @@ MHD_gnutls_x509_crq_get_pk_algorithm (MHD_gnutls_x509_crq_t crq, unsigned int *b result = MHD__gnutls_x509_get_pk_algorithm (crq->crq, - "certificationRequestInfo.subjectPKInfo", - bits); + "certificationRequestInfo.subjectPKInfo", + bits); if (result < 0) { MHD_gnutls_assert (); diff --git a/src/daemon/https/x509/dn.c b/src/daemon/https/x509/dn.c @@ -88,8 +88,8 @@ str_escape (char *str, char *buffer, unsigned int buffer_size) */ int MHD__gnutls_x509_parse_dn (ASN1_TYPE MHD__asn1_struct, - const char *MHD__asn1_rdn_name, char *buf, - size_t * sizeof_buf) + const char *MHD__asn1_rdn_name, char *buf, + size_t * sizeof_buf) { MHD_gtls_string out_str; int k2, k1, result; @@ -115,7 +115,8 @@ MHD__gnutls_x509_parse_dn (ASN1_TYPE MHD__asn1_struct, else *sizeof_buf = 0; - MHD_gtls_string_init (&out_str, MHD_gnutls_malloc, MHD_gnutls_realloc, MHD_gnutls_free); + MHD_gtls_string_init (&out_str, MHD_gnutls_malloc, MHD_gnutls_realloc, + MHD_gnutls_free); k1 = 0; do @@ -125,13 +126,14 @@ MHD__gnutls_x509_parse_dn (ASN1_TYPE MHD__asn1_struct, /* create a string like "tbsCertList.issuer.rdnSequence.?1" */ if (MHD__asn1_rdn_name[0] != 0) - snprintf (tmpbuffer1, sizeof (tmpbuffer1), "%s.?%u", MHD__asn1_rdn_name, - k1); + snprintf (tmpbuffer1, sizeof (tmpbuffer1), "%s.?%u", + MHD__asn1_rdn_name, k1); else snprintf (tmpbuffer1, sizeof (tmpbuffer1), "?%u", k1); len = sizeof (value) - 1; - result = MHD__asn1_read_value (MHD__asn1_struct, tmpbuffer1, value, &len); + result = + MHD__asn1_read_value (MHD__asn1_struct, tmpbuffer1, value, &len); if (result == ASN1_ELEMENT_NOT_FOUND) { @@ -162,7 +164,8 @@ MHD__gnutls_x509_parse_dn (ASN1_TYPE MHD__asn1_struct, */ len = sizeof (value) - 1; - result = MHD__asn1_read_value (MHD__asn1_struct, tmpbuffer2, value, &len); + result = + MHD__asn1_read_value (MHD__asn1_struct, tmpbuffer2, value, &len); if (result == ASN1_ELEMENT_NOT_FOUND) break; @@ -179,7 +182,8 @@ MHD__gnutls_x509_parse_dn (ASN1_TYPE MHD__asn1_struct, MHD_gtls_str_cat (tmpbuffer3, sizeof (tmpbuffer3), ".type"); len = sizeof (oid) - 1; - result = MHD__asn1_read_value (MHD__asn1_struct, tmpbuffer3, oid, &len); + result = + MHD__asn1_read_value (MHD__asn1_struct, tmpbuffer3, oid, &len); if (result == ASN1_ELEMENT_NOT_FOUND) break; @@ -196,7 +200,8 @@ MHD__gnutls_x509_parse_dn (ASN1_TYPE MHD__asn1_struct, MHD_gtls_str_cat (tmpbuffer3, sizeof (tmpbuffer3), ".value"); len = 0; - result = MHD__asn1_read_value (MHD__asn1_struct, tmpbuffer3, NULL, &len); + result = + MHD__asn1_read_value (MHD__asn1_struct, tmpbuffer3, NULL, &len); value2 = MHD_gnutls_malloc (len); if (value2 == NULL) @@ -206,7 +211,8 @@ MHD__gnutls_x509_parse_dn (ASN1_TYPE MHD__asn1_struct, goto cleanup; } - result = MHD__asn1_read_value (MHD__asn1_struct, tmpbuffer3, value2, &len); + result = + MHD__asn1_read_value (MHD__asn1_struct, tmpbuffer3, value2, &len); if (result != ASN1_SUCCESS) { @@ -268,12 +274,14 @@ MHD__gnutls_x509_parse_dn (ASN1_TYPE MHD__asn1_struct, if (printable) result = MHD__gnutls_x509_oid_data2string (oid, - value2, len, - string, &sizeof_string); + value2, len, + string, &sizeof_string); if (!printable || result < 0) result = - MHD__gnutls_x509_data2hex ((const unsigned char*) value2, len, (unsigned char*) string, &sizeof_string); + MHD__gnutls_x509_data2hex ((const unsigned char *) value2, len, + (unsigned char *) string, + &sizeof_string); if (result < 0) { @@ -338,10 +346,10 @@ cleanup: */ int MHD__gnutls_x509_parse_dn_oid (ASN1_TYPE MHD__asn1_struct, - const char *MHD__asn1_rdn_name, - const char *given_oid, int indx, - unsigned int raw_flag, - void *buf, size_t * sizeof_buf) + const char *MHD__asn1_rdn_name, + const char *given_oid, int indx, + unsigned int raw_flag, + void *buf, size_t * sizeof_buf) { int k2, k1, result; char tmpbuffer1[MAX_NAME_SIZE]; @@ -366,13 +374,14 @@ MHD__gnutls_x509_parse_dn_oid (ASN1_TYPE MHD__asn1_struct, /* create a string like "tbsCertList.issuer.rdnSequence.?1" */ if (MHD__asn1_rdn_name[0] != 0) - snprintf (tmpbuffer1, sizeof (tmpbuffer1), "%s.?%u", MHD__asn1_rdn_name, - k1); + snprintf (tmpbuffer1, sizeof (tmpbuffer1), "%s.?%u", + MHD__asn1_rdn_name, k1); else snprintf (tmpbuffer1, sizeof (tmpbuffer1), "?%u", k1); len = sizeof (value) - 1; - result = MHD__asn1_read_value (MHD__asn1_struct, tmpbuffer1, value, &len); + result = + MHD__asn1_read_value (MHD__asn1_struct, tmpbuffer1, value, &len); if (result == ASN1_ELEMENT_NOT_FOUND) { @@ -404,7 +413,8 @@ MHD__gnutls_x509_parse_dn_oid (ASN1_TYPE MHD__asn1_struct, */ len = sizeof (value) - 1; - result = MHD__asn1_read_value (MHD__asn1_struct, tmpbuffer2, value, &len); + result = + MHD__asn1_read_value (MHD__asn1_struct, tmpbuffer2, value, &len); if (result == ASN1_ELEMENT_NOT_FOUND) { @@ -423,7 +433,8 @@ MHD__gnutls_x509_parse_dn_oid (ASN1_TYPE MHD__asn1_struct, MHD_gtls_str_cat (tmpbuffer3, sizeof (tmpbuffer3), ".type"); len = sizeof (oid) - 1; - result = MHD__asn1_read_value (MHD__asn1_struct, tmpbuffer3, oid, &len); + result = + MHD__asn1_read_value (MHD__asn1_struct, tmpbuffer3, oid, &len); if (result == ASN1_ELEMENT_NOT_FOUND) break; @@ -443,7 +454,9 @@ MHD__gnutls_x509_parse_dn_oid (ASN1_TYPE MHD__asn1_struct, MHD_gtls_str_cat (tmpbuffer3, sizeof (tmpbuffer3), ".value"); len = *sizeof_buf; - result = MHD__asn1_read_value (MHD__asn1_struct, tmpbuffer3, buf, &len); + result = + MHD__asn1_read_value (MHD__asn1_struct, tmpbuffer3, buf, + &len); if (result != ASN1_SUCCESS) { @@ -474,10 +487,12 @@ MHD__gnutls_x509_parse_dn_oid (ASN1_TYPE MHD__asn1_struct, if (printable == 1) result = MHD__gnutls_x509_oid_data2string (oid, buf, len, - cbuf, sizeof_buf); + cbuf, sizeof_buf); else result = - MHD__gnutls_x509_data2hex (buf, len, (unsigned char*) cbuf, sizeof_buf); + MHD__gnutls_x509_data2hex (buf, len, + (unsigned char *) cbuf, + sizeof_buf); if (result < 0) { @@ -515,8 +530,8 @@ cleanup: */ int MHD__gnutls_x509_get_dn_oid (ASN1_TYPE MHD__asn1_struct, - const char *MHD__asn1_rdn_name, - int indx, void *_oid, size_t * sizeof_oid) + const char *MHD__asn1_rdn_name, + int indx, void *_oid, size_t * sizeof_oid) { int k2, k1, result; char tmpbuffer1[MAX_NAME_SIZE]; @@ -535,13 +550,14 @@ MHD__gnutls_x509_get_dn_oid (ASN1_TYPE MHD__asn1_struct, /* create a string like "tbsCertList.issuer.rdnSequence.?1" */ if (MHD__asn1_rdn_name[0] != 0) - snprintf (tmpbuffer1, sizeof (tmpbuffer1), "%s.?%u", MHD__asn1_rdn_name, - k1); + snprintf (tmpbuffer1, sizeof (tmpbuffer1), "%s.?%u", + MHD__asn1_rdn_name, k1); else snprintf (tmpbuffer1, sizeof (tmpbuffer1), "?%u", k1); len = sizeof (value) - 1; - result = MHD__asn1_read_value (MHD__asn1_struct, tmpbuffer1, value, &len); + result = + MHD__asn1_read_value (MHD__asn1_struct, tmpbuffer1, value, &len); if (result == ASN1_ELEMENT_NOT_FOUND) { @@ -573,7 +589,8 @@ MHD__gnutls_x509_get_dn_oid (ASN1_TYPE MHD__asn1_struct, */ len = sizeof (value) - 1; - result = MHD__asn1_read_value (MHD__asn1_struct, tmpbuffer2, value, &len); + result = + MHD__asn1_read_value (MHD__asn1_struct, tmpbuffer2, value, &len); if (result == ASN1_ELEMENT_NOT_FOUND) { @@ -592,7 +609,8 @@ MHD__gnutls_x509_get_dn_oid (ASN1_TYPE MHD__asn1_struct, MHD_gtls_str_cat (tmpbuffer3, sizeof (tmpbuffer3), ".type"); len = sizeof (oid) - 1; - result = MHD__asn1_read_value (MHD__asn1_struct, tmpbuffer3, oid, &len); + result = + MHD__asn1_read_value (MHD__asn1_struct, tmpbuffer3, oid, &len); if (result == ASN1_ELEMENT_NOT_FOUND) break; @@ -640,10 +658,10 @@ cleanup: */ int MHD__gnutls_x509_encode_and_write_attribute (const char *given_oid, - ASN1_TYPE MHD__asn1_struct, - const char *where, - const void *_data, - int sizeof_data, int multi) + ASN1_TYPE MHD__asn1_struct, + const char *where, + const void *_data, + int sizeof_data, int multi) { const char *val_name; const opaque *data = _data; @@ -654,7 +672,8 @@ MHD__gnutls_x509_encode_and_write_attribute (const char *given_oid, /* Find how to encode the data. */ - val_name = MHD__asn1_find_structure_from_oid (MHD__gnutls_get_pkix (), given_oid); + val_name = + MHD__asn1_find_structure_from_oid (MHD__gnutls_get_pkix (), given_oid); if (val_name == NULL) { MHD_gnutls_assert (); @@ -736,7 +755,8 @@ MHD__gnutls_x509_encode_and_write_attribute (const char *given_oid, } - result = MHD__gnutls_x509_der_encode_and_copy (c2, "", MHD__asn1_struct, tmp, 0); + result = + MHD__gnutls_x509_der_encode_and_copy (c2, "", MHD__asn1_struct, tmp, 0); if (result < 0) { MHD_gnutls_assert (); @@ -763,8 +783,9 @@ MHD__gnutls_x509_encode_and_write_attribute (const char *given_oid, */ static int MHD__gnutls_x509_write_attribute (const char *given_oid, - ASN1_TYPE MHD__asn1_struct, const char *where, - const void *_data, int sizeof_data) + ASN1_TYPE MHD__asn1_struct, + const char *where, const void *_data, + int sizeof_data) { char tmp[128]; int result; @@ -808,9 +829,10 @@ MHD__gnutls_x509_write_attribute (const char *given_oid, */ int MHD__gnutls_x509_decode_and_read_attribute (ASN1_TYPE MHD__asn1_struct, - const char *where, char *oid, - int oid_size, MHD_gnutls_datum_t * value, - int multi, int octet_string) + const char *where, char *oid, + int oid_size, + MHD_gnutls_datum_t * value, + int multi, int octet_string) { char tmpbuffer[128]; int len, result; @@ -840,7 +862,8 @@ MHD__gnutls_x509_decode_and_read_attribute (ASN1_TYPE MHD__asn1_struct, MHD_gtls_str_cat (tmpbuffer, sizeof (tmpbuffer), "s.?1"); /* .values.?1 */ result = - MHD__gnutls_x509_read_value (MHD__asn1_struct, tmpbuffer, value, octet_string); + MHD__gnutls_x509_read_value (MHD__asn1_struct, tmpbuffer, value, + octet_string); if (result < 0) { MHD_gnutls_assert (); @@ -860,8 +883,9 @@ MHD__gnutls_x509_decode_and_read_attribute (ASN1_TYPE MHD__asn1_struct, */ int MHD__gnutls_x509_set_dn_oid (ASN1_TYPE MHD__asn1_struct, - const char *MHD__asn1_name, const char *given_oid, - int raw_flag, const char *name, int sizeof_name) + const char *MHD__asn1_name, + const char *given_oid, int raw_flag, + const char *name, int sizeof_name) { int result; char tmp[MAX_NAME_SIZE], MHD__asn1_rdn_name[MAX_NAME_SIZE]; @@ -874,19 +898,24 @@ MHD__gnutls_x509_set_dn_oid (ASN1_TYPE MHD__asn1_struct, /* create the rdnSequence */ - result = MHD__asn1_write_value (MHD__asn1_struct, MHD__asn1_name, "rdnSequence", 1); + result = + MHD__asn1_write_value (MHD__asn1_struct, MHD__asn1_name, "rdnSequence", + 1); if (result != ASN1_SUCCESS) { MHD_gnutls_assert (); return MHD_gtls_asn2err (result); } - MHD_gtls_str_cpy (MHD__asn1_rdn_name, sizeof (MHD__asn1_rdn_name), MHD__asn1_name); - MHD_gtls_str_cat (MHD__asn1_rdn_name, sizeof (MHD__asn1_rdn_name), ".rdnSequence"); + MHD_gtls_str_cpy (MHD__asn1_rdn_name, sizeof (MHD__asn1_rdn_name), + MHD__asn1_name); + MHD_gtls_str_cat (MHD__asn1_rdn_name, sizeof (MHD__asn1_rdn_name), + ".rdnSequence"); /* create a new element */ - result = MHD__asn1_write_value (MHD__asn1_struct, MHD__asn1_rdn_name, "NEW", 1); + result = + MHD__asn1_write_value (MHD__asn1_struct, MHD__asn1_rdn_name, "NEW", 1); if (result != ASN1_SUCCESS) { MHD_gnutls_assert (); @@ -915,14 +944,15 @@ MHD__gnutls_x509_set_dn_oid (ASN1_TYPE MHD__asn1_struct, { result = MHD__gnutls_x509_encode_and_write_attribute (given_oid, - MHD__asn1_struct, - tmp, name, sizeof_name, 0); + MHD__asn1_struct, + tmp, name, sizeof_name, + 0); } else { result = MHD__gnutls_x509_write_attribute (given_oid, MHD__asn1_struct, - tmp, name, sizeof_name); + tmp, name, sizeof_name); } if (result < 0) @@ -952,7 +982,7 @@ MHD__gnutls_x509_set_dn_oid (ASN1_TYPE MHD__asn1_struct, **/ int MHD_gnutls_x509_rdn_get (const MHD_gnutls_datum_t * idn, - char *buf, size_t * sizeof_buf) + char *buf, size_t * sizeof_buf) { int result; ASN1_TYPE dn = ASN1_TYPE_EMPTY; @@ -969,7 +999,7 @@ MHD_gnutls_x509_rdn_get (const MHD_gnutls_datum_t * idn, if ((result = MHD__asn1_create_element (MHD__gnutls_get_pkix (), - "PKIX1.Name", &dn)) != ASN1_SUCCESS) + "PKIX1.Name", &dn)) != ASN1_SUCCESS) { MHD_gnutls_assert (); return MHD_gtls_asn2err (result); @@ -1010,9 +1040,10 @@ MHD_gnutls_x509_rdn_get (const MHD_gnutls_datum_t * idn, * **/ int -MHD_gnutls_x509_rdn_get_by_oid (const MHD_gnutls_datum_t * idn, const char *oid, - int indx, unsigned int raw_flag, - void *buf, size_t * sizeof_buf) +MHD_gnutls_x509_rdn_get_by_oid (const MHD_gnutls_datum_t * idn, + const char *oid, int indx, + unsigned int raw_flag, void *buf, + size_t * sizeof_buf) { int result; ASN1_TYPE dn = ASN1_TYPE_EMPTY; @@ -1024,7 +1055,7 @@ MHD_gnutls_x509_rdn_get_by_oid (const MHD_gnutls_datum_t * idn, const char *oid, if ((result = MHD__asn1_create_element (MHD__gnutls_get_pkix (), - "PKIX1.Name", &dn)) != ASN1_SUCCESS) + "PKIX1.Name", &dn)) != ASN1_SUCCESS) { MHD_gnutls_assert (); return MHD_gtls_asn2err (result); @@ -1041,7 +1072,7 @@ MHD_gnutls_x509_rdn_get_by_oid (const MHD_gnutls_datum_t * idn, const char *oid, result = MHD__gnutls_x509_parse_dn_oid (dn, "rdnSequence", oid, indx, - raw_flag, buf, sizeof_buf); + raw_flag, buf, sizeof_buf); MHD__asn1_delete_structure (&dn); return result; @@ -1064,7 +1095,7 @@ MHD_gnutls_x509_rdn_get_by_oid (const MHD_gnutls_datum_t * idn, const char *oid, **/ int MHD_gnutls_x509_rdn_get_oid (const MHD_gnutls_datum_t * idn, - int indx, void *buf, size_t * sizeof_buf) + int indx, void *buf, size_t * sizeof_buf) { int result; ASN1_TYPE dn = ASN1_TYPE_EMPTY; @@ -1076,7 +1107,7 @@ MHD_gnutls_x509_rdn_get_oid (const MHD_gnutls_datum_t * idn, if ((result = MHD__asn1_create_element (MHD__gnutls_get_pkix (), - "PKIX1.Name", &dn)) != ASN1_SUCCESS) + "PKIX1.Name", &dn)) != ASN1_SUCCESS) { MHD_gnutls_assert (); return MHD_gtls_asn2err (result); @@ -1091,7 +1122,8 @@ MHD_gnutls_x509_rdn_get_oid (const MHD_gnutls_datum_t * idn, return MHD_gtls_asn2err (result); } - result = MHD__gnutls_x509_get_dn_oid (dn, "rdnSequence", indx, buf, sizeof_buf); + result = + MHD__gnutls_x509_get_dn_oid (dn, "rdnSequence", indx, buf, sizeof_buf); MHD__asn1_delete_structure (&dn); return result; @@ -1108,7 +1140,7 @@ MHD_gnutls_x509_rdn_get_oid (const MHD_gnutls_datum_t * idn, */ int MHD__gnutls_x509_compare_raw_dn (const MHD_gnutls_datum_t * dn1, - const MHD_gnutls_datum_t * dn2) + const MHD_gnutls_datum_t * dn2) { if (dn1->size != dn2->size) diff --git a/src/daemon/https/x509/dn.h b/src/daemon/https/x509/dn.h @@ -38,21 +38,23 @@ #define OID_PKCS9_EMAIL "1.2.840.113549.1.9.1" int MHD__gnutls_x509_parse_dn (ASN1_TYPE MHD__asn1_struct, - const char *MHD__asn1_rdn_name, char *buf, - size_t * sizeof_buf); + const char *MHD__asn1_rdn_name, char *buf, + size_t * sizeof_buf); int MHD__gnutls_x509_parse_dn_oid (ASN1_TYPE MHD__asn1_struct, - const char *MHD__asn1_rdn_name, const char *oid, - int indx, unsigned int raw_flag, void *buf, - size_t * sizeof_buf); + const char *MHD__asn1_rdn_name, + const char *oid, int indx, + unsigned int raw_flag, void *buf, + size_t * sizeof_buf); int MHD__gnutls_x509_set_dn_oid (ASN1_TYPE MHD__asn1_struct, - const char *MHD__asn1_rdn_name, const char *oid, - int raw_flag, const char *name, int sizeof_name); + const char *MHD__asn1_rdn_name, + const char *oid, int raw_flag, + const char *name, int sizeof_name); int MHD__gnutls_x509_get_dn_oid (ASN1_TYPE MHD__asn1_struct, - const char *MHD__asn1_rdn_name, - int indx, void *_oid, size_t * sizeof_oid); + const char *MHD__asn1_rdn_name, + int indx, void *_oid, size_t * sizeof_oid); #endif diff --git a/src/daemon/https/x509/dsa.h b/src/daemon/https/x509/dsa.h @@ -22,4 +22,5 @@ * */ -int MHD__gnutls_dsa_generate_params (mpi_t * resarr, int *resarr_len, int bits); +int MHD__gnutls_dsa_generate_params (mpi_t * resarr, int *resarr_len, + int bits); diff --git a/src/daemon/https/x509/extensions.c b/src/daemon/https/x509/extensions.c @@ -46,8 +46,9 @@ */ int MHD__gnutls_x509_crt_get_extension (MHD_gnutls_x509_crt_t cert, - const char *extension_id, int indx, - MHD_gnutls_datum_t * ret, unsigned int *_critical) + const char *extension_id, int indx, + MHD_gnutls_datum_t * ret, + unsigned int *_critical) { int k, result, len; char name[MAX_NAME_SIZE], name2[MAX_NAME_SIZE]; @@ -136,7 +137,8 @@ MHD__gnutls_x509_crt_get_extension (MHD_gnutls_x509_crt_t cert, MHD_gtls_str_cpy (name2, sizeof (name2), name); MHD_gtls_str_cat (name2, sizeof (name2), ".extnValue"); - result = MHD__gnutls_x509_read_value (cert->cert, name2, &value, 0); + result = + MHD__gnutls_x509_read_value (cert->cert, name2, &value, 0); if (result < 0) { MHD_gnutls_assert (); @@ -177,7 +179,8 @@ MHD__gnutls_x509_crt_get_extension (MHD_gnutls_x509_crt_t cert, */ int MHD__gnutls_x509_crt_get_extension_oid (MHD_gnutls_x509_crt_t cert, - int indx, void *oid, size_t * sizeof_oid) + int indx, void *oid, + size_t * sizeof_oid) { int k, result, len; char name[MAX_NAME_SIZE], name2[MAX_NAME_SIZE]; @@ -264,7 +267,7 @@ MHD__gnutls_x509_crt_get_extension_oid (MHD_gnutls_x509_crt_t cert, */ int MHD__gnutls_x509_ext_extract_keyUsage (uint16_t * keyUsage, - opaque * extnValue, int extnValueLen) + opaque * extnValue, int extnValueLen) { ASN1_TYPE ext = ASN1_TYPE_EMPTY; int len, result; @@ -309,16 +312,17 @@ MHD__gnutls_x509_ext_extract_keyUsage (uint16_t * keyUsage, */ int MHD__gnutls_x509_ext_extract_basicConstraints (int *CA, - int *pathLenConstraint, - opaque * extnValue, - int extnValueLen) + int *pathLenConstraint, + opaque * extnValue, + int extnValueLen) { ASN1_TYPE ext = ASN1_TYPE_EMPTY; char str[128]; int len, result; if ((result = MHD__asn1_create_element - (MHD__gnutls_get_pkix (), "PKIX1.BasicConstraints", &ext)) != ASN1_SUCCESS) + (MHD__gnutls_get_pkix (), "PKIX1.BasicConstraints", + &ext)) != ASN1_SUCCESS) { MHD_gnutls_assert (); return MHD_gtls_asn2err (result); @@ -335,7 +339,8 @@ MHD__gnutls_x509_ext_extract_basicConstraints (int *CA, if (pathLenConstraint) { result = MHD__gnutls_x509_read_uint (ext, "pathLenConstraint", - (unsigned int*) pathLenConstraint); + (unsigned int *) + pathLenConstraint); if (result == GNUTLS_E_ASN1_ELEMENT_NOT_FOUND) *pathLenConstraint = -1; else if (result != GNUTLS_E_SUCCESS) diff --git a/src/daemon/https/x509/extensions.h b/src/daemon/https/x509/extensions.h @@ -23,16 +23,17 @@ */ int MHD__gnutls_x509_crt_get_extension (MHD_gnutls_x509_crt_t cert, - const char *extension_id, int indx, - MHD_gnutls_datum_t * ret, - unsigned int *critical); + const char *extension_id, int indx, + MHD_gnutls_datum_t * ret, + unsigned int *critical); int MHD__gnutls_x509_crt_get_extension_oid (MHD_gnutls_x509_crt_t cert, - int indx, void *ret, - size_t * ret_size); + int indx, void *ret, + size_t * ret_size); int MHD__gnutls_x509_ext_extract_keyUsage (uint16_t * keyUsage, - opaque * extnValue, int extnValueLen); + opaque * extnValue, + int extnValueLen); int MHD__gnutls_x509_ext_extract_basicConstraints (int *CA, - int *pathLenConstraint, - opaque * extnValue, - int extnValueLen); + int *pathLenConstraint, + opaque * extnValue, + int extnValueLen); diff --git a/src/daemon/https/x509/mpi.c b/src/daemon/https/x509/mpi.c @@ -44,8 +44,9 @@ MHD__gnutls_x509_read_rsa_params (opaque * der, int dersize, mpi_t * params) ASN1_TYPE spk = ASN1_TYPE_EMPTY; if ((result = - MHD__asn1_create_element (MHD__gnutls_getMHD__gnutls_asn (), "GNUTLS.RSAPublicKey", - &spk)) != ASN1_SUCCESS) + MHD__asn1_create_element (MHD__gnutls_getMHD__gnutls_asn (), + "GNUTLS.RSAPublicKey", + &spk)) != ASN1_SUCCESS) { MHD_gnutls_assert (); return MHD_gtls_asn2err (result); @@ -94,7 +95,7 @@ MHD__gnutls_x509_read_dsa_params (opaque * der, int dersize, mpi_t * params) if ((result = MHD__asn1_create_element (MHD__gnutls_get_pkix (), "PKIX1.Dss-Parms", - &spk)) != ASN1_SUCCESS) + &spk)) != ASN1_SUCCESS) { MHD_gnutls_assert (); return MHD_gtls_asn2err (result); @@ -161,8 +162,9 @@ MHD__gnutls_x509_read_der_int (opaque * der, int dersize, mpi_t * out) /* == INTEGER */ if ((result = - MHD__asn1_create_element (MHD__gnutls_getMHD__gnutls_asn (), "GNUTLS.DSAPublicKey", - &spk)) != ASN1_SUCCESS) + MHD__asn1_create_element (MHD__gnutls_getMHD__gnutls_asn (), + "GNUTLS.DSAPublicKey", + &spk)) != ASN1_SUCCESS) { MHD_gnutls_assert (); return MHD_gtls_asn2err (result); @@ -206,7 +208,7 @@ MHD__gnutls_x509_read_dsa_pubkey (opaque * der, int dersize, mpi_t * params) */ int MHD__gnutls_x509_crt_get_mpis (MHD_gnutls_x509_crt_t cert, - mpi_t * params, int *params_size) + mpi_t * params, int *params_size) { int result; int pk_algorithm; @@ -220,8 +222,8 @@ MHD__gnutls_x509_crt_get_mpis (MHD_gnutls_x509_crt_t cert, */ result = MHD__gnutls_x509_read_value (cert->cert, - "tbsCertificate.subjectPublicKeyInfo.subjectPublicKey", - &tmp, 2); + "tbsCertificate.subjectPublicKeyInfo.subjectPublicKey", + &tmp, 2); if (result < 0) { @@ -276,7 +278,7 @@ error:MHD__gnutls_free_datum (&tmp); */ int MHD__gnutls_x509_write_rsa_params (mpi_t * params, - int params_size, MHD_gnutls_datum_t * der) + int params_size, MHD_gnutls_datum_t * der) { int result; ASN1_TYPE spk = ASN1_TYPE_EMPTY; @@ -292,8 +294,9 @@ MHD__gnutls_x509_write_rsa_params (mpi_t * params, } if ((result = - MHD__asn1_create_element (MHD__gnutls_getMHD__gnutls_asn (), "GNUTLS.RSAPublicKey", - &spk)) != ASN1_SUCCESS) + MHD__asn1_create_element (MHD__gnutls_getMHD__gnutls_asn (), + "GNUTLS.RSAPublicKey", + &spk)) != ASN1_SUCCESS) { MHD_gnutls_assert (); return MHD_gtls_asn2err (result); @@ -334,11 +337,11 @@ cleanup:MHD__asn1_delete_structure (&spk); */ int MHD__gnutls_x509_write_sig_params (ASN1_TYPE dst, - const char *dst_name, - enum MHD_GNUTLS_PublicKeyAlgorithm - pk_algorithm, - enum MHD_GNUTLS_HashAlgorithm dig, - mpi_t * params, int params_size) + const char *dst_name, + enum MHD_GNUTLS_PublicKeyAlgorithm + pk_algorithm, + enum MHD_GNUTLS_HashAlgorithm dig, + mpi_t * params, int params_size) { int result; char name[128]; @@ -391,7 +394,7 @@ MHD__gnutls_x509_write_sig_params (ASN1_TYPE dst, */ int MHD__gnutls_x509_write_dsa_params (mpi_t * params, - int params_size, MHD_gnutls_datum_t * der) + int params_size, MHD_gnutls_datum_t * der) { int result; ASN1_TYPE spk = ASN1_TYPE_EMPTY; @@ -407,8 +410,9 @@ MHD__gnutls_x509_write_dsa_params (mpi_t * params, } if ((result = - MHD__asn1_create_element (MHD__gnutls_getMHD__gnutls_asn (), "GNUTLS.DSAParameters", - &spk)) != ASN1_SUCCESS) + MHD__asn1_create_element (MHD__gnutls_getMHD__gnutls_asn (), + "GNUTLS.DSAParameters", + &spk)) != ASN1_SUCCESS) { MHD_gnutls_assert (); return MHD_gtls_asn2err (result); @@ -456,7 +460,8 @@ cleanup:MHD__asn1_delete_structure (&spk); */ int MHD__gnutls_x509_write_dsa_public_key (mpi_t * params, - int params_size, MHD_gnutls_datum_t * der) + int params_size, + MHD_gnutls_datum_t * der) { int result; ASN1_TYPE spk = ASN1_TYPE_EMPTY; @@ -472,8 +477,9 @@ MHD__gnutls_x509_write_dsa_public_key (mpi_t * params, } if ((result = - MHD__asn1_create_element (MHD__gnutls_getMHD__gnutls_asn (), "GNUTLS.DSAPublicKey", - &spk)) != ASN1_SUCCESS) + MHD__asn1_create_element (MHD__gnutls_getMHD__gnutls_asn (), + "GNUTLS.DSAPublicKey", + &spk)) != ASN1_SUCCESS) { MHD_gnutls_assert (); return MHD_gtls_asn2err (result); @@ -505,7 +511,8 @@ cleanup:MHD__asn1_delete_structure (&spk); * steps. */ int -MHD__gnutls_x509_read_uint (ASN1_TYPE node, const char *value, unsigned int *ret) +MHD__gnutls_x509_read_uint (ASN1_TYPE node, const char *value, + unsigned int *ret) { int len, result; opaque *tmpstr; @@ -557,7 +564,8 @@ MHD__gnutls_x509_read_uint (ASN1_TYPE node, const char *value, unsigned int *ret /* Writes the specified integer into the specified node. */ int -MHD__gnutls_x509_write_uint32 (ASN1_TYPE node, const char *value, uint32_t num) +MHD__gnutls_x509_write_uint32 (ASN1_TYPE node, const char *value, + uint32_t num) { opaque tmpstr[4]; int result; diff --git a/src/daemon/https/x509/mpi.h b/src/daemon/https/x509/mpi.h @@ -26,32 +26,35 @@ #include "x509.h" int MHD__gnutls_x509_crt_get_mpis (MHD_gnutls_x509_crt_t cert, - mpi_t * params, int *params_size); -int MHD__gnutls_x509_read_rsa_params (opaque * der, int dersize, mpi_t * params); -int MHD__gnutls_x509_read_dsa_pubkey (opaque * der, int dersize, mpi_t * params); -int MHD__gnutls_x509_read_dsa_params (opaque * der, int dersize, mpi_t * params); + mpi_t * params, int *params_size); +int MHD__gnutls_x509_read_rsa_params (opaque * der, int dersize, + mpi_t * params); +int MHD__gnutls_x509_read_dsa_pubkey (opaque * der, int dersize, + mpi_t * params); +int MHD__gnutls_x509_read_dsa_params (opaque * der, int dersize, + mpi_t * params); int MHD__gnutls_x509_write_rsa_params (mpi_t * params, int params_size, - MHD_gnutls_datum_t * der); + MHD_gnutls_datum_t * der); int MHD__gnutls_x509_write_dsa_params (mpi_t * params, int params_size, - MHD_gnutls_datum_t * der); -int MHD__gnutls_x509_write_dsa_public_key (mpi_t * params, int params_size, MHD_gnutls_datum_t * der); +int MHD__gnutls_x509_write_dsa_public_key (mpi_t * params, int params_size, + MHD_gnutls_datum_t * der); int MHD__gnutls_x509_read_uint (ASN1_TYPE node, const char *value, - unsigned int *ret); + unsigned int *ret); int MHD__gnutls_x509_read_der_int (opaque * der, int dersize, mpi_t * out); int MHD__gnutls_x509_read_int (ASN1_TYPE node, const char *value, - mpi_t * ret_mpi); + mpi_t * ret_mpi); int MHD__gnutls_x509_write_int (ASN1_TYPE node, const char *value, mpi_t mpi, - int lz); + int lz); int MHD__gnutls_x509_write_uint32 (ASN1_TYPE node, const char *value, - uint32_t num); + uint32_t num); int MHD__gnutls_x509_write_sig_params (ASN1_TYPE dst, const char *dst_name, - enum MHD_GNUTLS_PublicKeyAlgorithm - pk_algorithm, - enum MHD_GNUTLS_HashAlgorithm, - mpi_t * params, int params_size); + enum MHD_GNUTLS_PublicKeyAlgorithm + pk_algorithm, + enum MHD_GNUTLS_HashAlgorithm, + mpi_t * params, int params_size); diff --git a/src/daemon/https/x509/pkcs12.h b/src/daemon/https/x509/pkcs12.h @@ -81,37 +81,40 @@ extern "C" int MHD_gnutls_pkcs12_init (MHD_gnutls_pkcs12_t * pkcs12); void MHD_gnutls_pkcs12_deinit (MHD_gnutls_pkcs12_t pkcs12); int MHD_gnutls_pkcs12_import (MHD_gnutls_pkcs12_t pkcs12, - const MHD_gnutls_datum_t * data, - MHD_gnutls_x509_crt_fmt_t format, unsigned int flags); + const MHD_gnutls_datum_t * data, + MHD_gnutls_x509_crt_fmt_t format, + unsigned int flags); int MHD_gnutls_pkcs12_export (MHD_gnutls_pkcs12_t pkcs12, - MHD_gnutls_x509_crt_fmt_t format, - void *output_data, size_t * output_data_size); + MHD_gnutls_x509_crt_fmt_t format, + void *output_data, size_t * output_data_size); - int MHD_gnutls_pkcs12_bag_decrypt (MHD_gnutls_pkcs12_bag_t bag, const char *pass); + int MHD_gnutls_pkcs12_bag_decrypt (MHD_gnutls_pkcs12_bag_t bag, + const char *pass); int MHD_gnutls_pkcs12_bag_encrypt (MHD_gnutls_pkcs12_bag_t bag, - const char *pass, unsigned int flags); + const char *pass, unsigned int flags); int MHD_gnutls_pkcs12_bag_get_data (MHD_gnutls_pkcs12_bag_t bag, - int indx, MHD_gnutls_datum_t * data); + int indx, MHD_gnutls_datum_t * data); int MHD_gnutls_pkcs12_bag_set_data (MHD_gnutls_pkcs12_bag_t bag, - MHD_gnutls_pkcs12_bag_type_t type, - const MHD_gnutls_datum_t * data); + MHD_gnutls_pkcs12_bag_type_t type, + const MHD_gnutls_datum_t * data); int MHD_gnutls_pkcs12_bag_set_crl (MHD_gnutls_pkcs12_bag_t bag, - MHD_gnutls_x509_crl_t crl); + MHD_gnutls_x509_crl_t crl); int MHD_gnutls_pkcs12_bag_set_crt (MHD_gnutls_pkcs12_bag_t bag, - MHD_gnutls_x509_crt_t crt); + MHD_gnutls_x509_crt_t crt); int MHD_gnutls_pkcs12_bag_get_count (MHD_gnutls_pkcs12_bag_t bag); int MHD_gnutls_pkcs12_bag_get_key_id (MHD_gnutls_pkcs12_bag_t bag, - int indx, MHD_gnutls_datum_t * id); + int indx, MHD_gnutls_datum_t * id); int MHD_gnutls_pkcs12_bag_set_key_id (MHD_gnutls_pkcs12_bag_t bag, - int indx, const MHD_gnutls_datum_t * id); + int indx, + const MHD_gnutls_datum_t * id); int MHD_gnutls_pkcs12_bag_get_friendly_name (MHD_gnutls_pkcs12_bag_t bag, - int indx, char **name); + int indx, char **name); int MHD_gnutls_pkcs12_bag_set_friendly_name (MHD_gnutls_pkcs12_bag_t bag, - int indx, const char *name); + int indx, const char *name); #ifdef __cplusplus } @@ -136,10 +139,10 @@ typedef enum schema_id } schema_id; int MHD_pkcs12_string_to_key (unsigned int id, - const opaque * salt, - unsigned int salt_size, - unsigned int iter, - const char *pw, - unsigned int req_keylen, opaque * keybuf); + const opaque * salt, + unsigned int salt_size, + unsigned int iter, + const char *pw, + unsigned int req_keylen, opaque * keybuf); #endif /* GNUTLS_PKCS12_H */ diff --git a/src/daemon/https/x509/pkcs12_encr.c b/src/daemon/https/x509/pkcs12_encr.c @@ -55,9 +55,9 @@ MHD_pkcs12_check_pass (const char *pass, size_t plen) */ int MHD_pkcs12_string_to_key (unsigned int id, const opaque * salt, - unsigned int salt_size, unsigned int iter, - const char *pw, unsigned int req_keylen, - opaque * keybuf) + unsigned int salt_size, unsigned int iter, + const char *pw, unsigned int req_keylen, + opaque * keybuf) { int rc; unsigned int i, j; @@ -115,13 +115,13 @@ MHD_pkcs12_string_to_key (unsigned int id, const opaque * salt, for (i = 0; i < 64; i++) { unsigned char lid = id & 0xFF; - MHD_gc_hash_write (md, 1, (const char*) &lid); + MHD_gc_hash_write (md, 1, (const char *) &lid); } - MHD_gc_hash_write (md, pw ? 128 : 64, (const char*) buf_i); + MHD_gc_hash_write (md, pw ? 128 : 64, (const char *) buf_i); memcpy (hash, MHD_gc_hash_read (md), 20); MHD_gc_hash_close (md); for (i = 1; i < iter; i++) - MHD_gc_hash_buffer (GC_SHA1, hash, 20, (char*) hash); + MHD_gc_hash_buffer (GC_SHA1, hash, 20, (char *) hash); for (i = 0; i < 20 && cur_keylen < req_keylen; i++) keybuf[cur_keylen++] = hash[i]; if (cur_keylen == req_keylen) diff --git a/src/daemon/https/x509/pkcs7.c b/src/daemon/https/x509/pkcs7.c @@ -69,7 +69,8 @@ _decode_pkcs7_signed_data (ASN1_TYPE pkcs7, ASN1_TYPE * sdata, } if ((result = MHD__asn1_create_element - (MHD__gnutls_get_pkix (), "PKIX1.pkcs-7-SignedData", &c2)) != ASN1_SUCCESS) + (MHD__gnutls_get_pkix (), "PKIX1.pkcs-7-SignedData", + &c2)) != ASN1_SUCCESS) { MHD_gnutls_assert (); return MHD_gtls_asn2err (result); @@ -158,8 +159,8 @@ MHD_gnutls_pkcs7_init (MHD_gnutls_pkcs7_t * pkcs7) if (*pkcs7) { int result = MHD__asn1_create_element (MHD__gnutls_get_pkix (), - "PKIX1.pkcs-7-ContentInfo", - &(*pkcs7)->pkcs7); + "PKIX1.pkcs-7-ContentInfo", + &(*pkcs7)->pkcs7); if (result != ASN1_SUCCESS) { MHD_gnutls_assert (); @@ -205,8 +206,9 @@ MHD_gnutls_pkcs7_deinit (MHD_gnutls_pkcs7_t pkcs7) * **/ int -MHD_gnutls_pkcs7_import (MHD_gnutls_pkcs7_t pkcs7, const MHD_gnutls_datum_t * data, - MHD_gnutls_x509_crt_fmt_t format) +MHD_gnutls_pkcs7_import (MHD_gnutls_pkcs7_t pkcs7, + const MHD_gnutls_datum_t * data, + MHD_gnutls_x509_crt_fmt_t format) { int result = 0, need_free = 0; MHD_gnutls_datum_t _data; @@ -224,7 +226,7 @@ MHD_gnutls_pkcs7_import (MHD_gnutls_pkcs7_t pkcs7, const MHD_gnutls_datum_t * da opaque *out; result = MHD__gnutls_fbase64_decode (PEM_PKCS7, data->data, data->size, - &out); + &out); if (result <= 0) { @@ -241,7 +243,8 @@ MHD_gnutls_pkcs7_import (MHD_gnutls_pkcs7_t pkcs7, const MHD_gnutls_datum_t * da } - result = MHD__asn1_der_decoding (&pkcs7->pkcs7, _data.data, _data.size, NULL); + result = + MHD__asn1_der_decoding (&pkcs7->pkcs7, _data.data, _data.size, NULL); if (result != ASN1_SUCCESS) { result = MHD_gtls_asn2err (result); @@ -277,8 +280,8 @@ cleanup: **/ int MHD_gnutls_pkcs7_get_crt_raw (MHD_gnutls_pkcs7_t pkcs7, - int indx, void *certificate, - size_t * certificate_size) + int indx, void *certificate, + size_t * certificate_size) { ASN1_TYPE c2 = ASN1_TYPE_EMPTY; int result, len; @@ -327,7 +330,7 @@ MHD_gnutls_pkcs7_get_crt_raw (MHD_gnutls_pkcs7_t pkcs7, int start, end; result = MHD__asn1_der_decoding_startEnd (c2, tmp.data, tmp.size, - root2, &start, &end); + root2, &start, &end); if (result != ASN1_SUCCESS) { @@ -432,14 +435,14 @@ MHD_gnutls_pkcs7_get_crt_count (MHD_gnutls_pkcs7_t pkcs7) **/ int MHD_gnutls_pkcs7_export (MHD_gnutls_pkcs7_t pkcs7, - MHD_gnutls_x509_crt_fmt_t format, void *output_data, - size_t * output_data_size) + MHD_gnutls_x509_crt_fmt_t format, void *output_data, + size_t * output_data_size) { if (pkcs7 == NULL) return GNUTLS_E_INVALID_REQUEST; return MHD__gnutls_x509_export_int (pkcs7->pkcs7, format, PEM_PKCS7, - output_data, output_data_size); + output_data, output_data_size); } /* Creates an empty signed data structure in the pkcs7 @@ -478,7 +481,7 @@ create_empty_signed_data (ASN1_TYPE pkcs7, ASN1_TYPE * sdata) /* id-data */ result = MHD__asn1_write_value (*sdata, "encapContentInfo.eContentType", - "1.2.840.113549.1.7.5", 1); + "1.2.840.113549.1.7.5", 1); if (result != ASN1_SUCCESS) { MHD_gnutls_assert (); @@ -486,7 +489,8 @@ create_empty_signed_data (ASN1_TYPE pkcs7, ASN1_TYPE * sdata) goto cleanup; } - result = MHD__asn1_write_value (*sdata, "encapContentInfo.eContent", NULL, 0); + result = + MHD__asn1_write_value (*sdata, "encapContentInfo.eContent", NULL, 0); if (result != ASN1_SUCCESS) { MHD_gnutls_assert (); @@ -531,7 +535,8 @@ cleanup: * **/ int -MHD_gnutls_pkcs7_set_crt_raw (MHD_gnutls_pkcs7_t pkcs7, const MHD_gnutls_datum_t * crt) +MHD_gnutls_pkcs7_set_crt_raw (MHD_gnutls_pkcs7_t pkcs7, + const MHD_gnutls_datum_t * crt) { ASN1_TYPE c2 = ASN1_TYPE_EMPTY; int result; @@ -585,7 +590,7 @@ MHD_gnutls_pkcs7_set_crt_raw (MHD_gnutls_pkcs7_t pkcs7, const MHD_gnutls_datum_t result = MHD__asn1_write_value (c2, "certificates.?LAST.certificate", crt->data, - crt->size); + crt->size); if (result != ASN1_SUCCESS) { MHD_gnutls_assert (); @@ -735,7 +740,7 @@ cleanup: **/ int MHD_gnutls_pkcs7_get_crl_raw (MHD_gnutls_pkcs7_t pkcs7, - int indx, void *crl, size_t * crl_size) + int indx, void *crl, size_t * crl_size) { ASN1_TYPE c2 = ASN1_TYPE_EMPTY; int result; @@ -763,7 +768,7 @@ MHD_gnutls_pkcs7_get_crl_raw (MHD_gnutls_pkcs7_t pkcs7, /* Get the raw CRL */ result = MHD__asn1_der_decoding_startEnd (c2, tmp.data, tmp.size, - root2, &start, &end); + root2, &start, &end); if (result != ASN1_SUCCESS) { @@ -849,7 +854,8 @@ MHD_gnutls_pkcs7_get_crl_count (MHD_gnutls_pkcs7_t pkcs7) * **/ int -MHD_gnutls_pkcs7_set_crl_raw (MHD_gnutls_pkcs7_t pkcs7, const MHD_gnutls_datum_t * crl) +MHD_gnutls_pkcs7_set_crl_raw (MHD_gnutls_pkcs7_t pkcs7, + const MHD_gnutls_datum_t * crl) { ASN1_TYPE c2 = ASN1_TYPE_EMPTY; int result; diff --git a/src/daemon/https/x509/privkey.h b/src/daemon/https/x509/privkey.h @@ -25,7 +25,8 @@ #include "x509.h" ASN1_TYPE MHD__gnutls_privkey_decode_pkcs1_rsa_key (const MHD_gnutls_datum_t * - raw_key, - MHD_gnutls_x509_privkey_t pkey); + raw_key, + MHD_gnutls_x509_privkey_t + pkey); int MHD__gnutls_asn1_encode_dsa (ASN1_TYPE * c2, mpi_t * params); diff --git a/src/daemon/https/x509/privkey_pkcs8.c b/src/daemon/https/x509/privkey_pkcs8.c @@ -82,7 +82,7 @@ static int decrypt_data (schema_id, ASN1_TYPE pkcs8_asn, const char *root, static int decode_private_key_info (const MHD_gnutls_datum_t * der, MHD_gnutls_x509_privkey_t pkey); static int readMHD_pkcs12_kdf_params (ASN1_TYPE pbes2_asn, - struct pbkdf2_params *params); + struct pbkdf2_params *params); #define PEM_PKCS8 "ENCRYPTED PRIVATE KEY" #define PEM_UNENCRYPTED_PKCS8 "PRIVATE KEY" @@ -106,7 +106,8 @@ check_schema (const char *oid) if (strcmp (oid, PKCS12_PBE_RC2_40_SHA1_OID) == 0) return PKCS12_RC2_40_SHA1; - MHD__gnutls_x509_log ("PKCS encryption schema OID '%s' is unsupported.\n", oid); + MHD__gnutls_x509_log ("PKCS encryption schema OID '%s' is unsupported.\n", + oid); return GNUTLS_E_UNKNOWN_CIPHER_TYPE; } @@ -134,8 +135,8 @@ read_pkcs_schema_params (schema_id schema, const char *password, */ if ((result = MHD__asn1_create_element (MHD__gnutls_get_pkix (), - "PKIX1.pkcs-5-PBES2-params", - &pbes2_asn)) != ASN1_SUCCESS) + "PKIX1.pkcs-5-PBES2-params", + &pbes2_asn)) != ASN1_SUCCESS) { MHD_gnutls_assert (); result = MHD_gtls_asn2err (result); @@ -197,8 +198,8 @@ read_pkcs_schema_params (schema_id schema, const char *password, if ((result = MHD__asn1_create_element (MHD__gnutls_get_pkix (), - "PKIX1.pkcs-12-PbeParams", - &pbes2_asn)) != ASN1_SUCCESS) + "PKIX1.pkcs-12-PbeParams", + &pbes2_asn)) != ASN1_SUCCESS) { MHD_gnutls_assert (); result = MHD_gtls_asn2err (result); @@ -226,9 +227,9 @@ read_pkcs_schema_params (schema_id schema, const char *password, { result = MHD_pkcs12_string_to_key (2 /*IV*/, kdf_params->salt, - kdf_params->salt_size, - kdf_params->iter_count, password, - enc_params->iv_size, enc_params->iv); + kdf_params->salt_size, + kdf_params->iter_count, password, + enc_params->iv_size, enc_params->iv); if (result < 0) { MHD_gnutls_assert (); @@ -270,15 +271,16 @@ decode_pkcs8_key (const MHD_gnutls_datum_t * raw_key, if ((result = MHD__asn1_create_element (MHD__gnutls_get_pkix (), - "PKIX1.pkcs-8-EncryptedPrivateKeyInfo", - &pkcs8_asn)) != ASN1_SUCCESS) + "PKIX1.pkcs-8-EncryptedPrivateKeyInfo", + &pkcs8_asn)) != ASN1_SUCCESS) { MHD_gnutls_assert (); result = MHD_gtls_asn2err (result); goto error; } - result = MHD__asn1_der_decoding (&pkcs8_asn, raw_key->data, raw_key->size, NULL); + result = + MHD__asn1_der_decoding (&pkcs8_asn, raw_key->data, raw_key->size, NULL); if (result != ASN1_SUCCESS) { MHD_gnutls_assert (); @@ -291,7 +293,7 @@ decode_pkcs8_key (const MHD_gnutls_datum_t * raw_key, len = sizeof (enc_oid); result = MHD__asn1_read_value (pkcs8_asn, "encryptionAlgorithm.algorithm", - enc_oid, &len); + enc_oid, &len); if (result != ASN1_SUCCESS) { MHD_gnutls_assert (); @@ -310,9 +312,9 @@ decode_pkcs8_key (const MHD_gnutls_datum_t * raw_key, */ result = MHD__asn1_der_decoding_startEnd (pkcs8_asn, raw_key->data, - raw_key->size, - "encryptionAlgorithm.parameters", - &params_start, &params_end); + raw_key->size, + "encryptionAlgorithm.parameters", + &params_start, &params_end); if (result != ASN1_SUCCESS) { MHD_gnutls_assert (); @@ -416,8 +418,8 @@ decode_private_key_info (const MHD_gnutls_datum_t * der, if ((result = MHD__asn1_create_element (MHD__gnutls_get_pkix (), - "PKIX1.pkcs-8-PrivateKeyInfo", - &pkcs8_asn)) != ASN1_SUCCESS) + "PKIX1.pkcs-8-PrivateKeyInfo", + &pkcs8_asn)) != ASN1_SUCCESS) { MHD_gnutls_assert (); result = MHD_gtls_asn2err (result); @@ -436,7 +438,8 @@ decode_private_key_info (const MHD_gnutls_datum_t * der, */ len = sizeof (oid); result = - MHD__asn1_read_value (pkcs8_asn, "privateKeyAlgorithm.algorithm", oid, &len); + MHD__asn1_read_value (pkcs8_asn, "privateKeyAlgorithm.algorithm", oid, + &len); if (result != ASN1_SUCCESS) { MHD_gnutls_assert (); @@ -446,7 +449,7 @@ decode_private_key_info (const MHD_gnutls_datum_t * der, /* we only support RSA and DSA private keys. */ - if (strcmp ((const char*) oid, PK_PKIX1_RSA_OID) == 0) + if (strcmp ((const char *) oid, PK_PKIX1_RSA_OID) == 0) pkey->pk_algorithm = MHD_GNUTLS_PK_RSA; else { @@ -502,9 +505,10 @@ error: **/ int MHD_gnutls_x509_privkey_import_pkcs8 (MHD_gnutls_x509_privkey_t key, - const MHD_gnutls_datum_t * data, - MHD_gnutls_x509_crt_fmt_t format, - const char *password, unsigned int flags) + const MHD_gnutls_datum_t * data, + MHD_gnutls_x509_crt_fmt_t format, + const char *password, + unsigned int flags) { int result = 0, need_free = 0; MHD_gnutls_datum_t _data; @@ -530,13 +534,14 @@ MHD_gnutls_x509_privkey_import_pkcs8 (MHD_gnutls_x509_privkey_t key, */ result = MHD__gnutls_fbase64_decode (PEM_UNENCRYPTED_PKCS8, - data->data, data->size, &out); + data->data, data->size, &out); if (result < 0) { /* Try the encrypted header */ result = - MHD__gnutls_fbase64_decode (PEM_PKCS8, data->data, data->size, &out); + MHD__gnutls_fbase64_decode (PEM_PKCS8, data->data, data->size, + &out); if (result <= 0) { @@ -589,7 +594,8 @@ cleanup: */ static int read_pbkdf2_params (ASN1_TYPE pbes2_asn, - const MHD_gnutls_datum_t * der, struct pbkdf2_params *params) + const MHD_gnutls_datum_t * der, + struct pbkdf2_params *params) { int params_start, params_end; int params_len, len, result; @@ -602,7 +608,8 @@ read_pbkdf2_params (ASN1_TYPE pbes2_asn, */ len = sizeof (oid); result = - MHD__asn1_read_value (pbes2_asn, "keyDerivationFunc.algorithm", oid, &len); + MHD__asn1_read_value (pbes2_asn, "keyDerivationFunc.algorithm", oid, + &len); if (result != ASN1_SUCCESS) { MHD_gnutls_assert (); @@ -620,8 +627,8 @@ read_pbkdf2_params (ASN1_TYPE pbes2_asn, result = MHD__asn1_der_decoding_startEnd (pbes2_asn, der->data, der->size, - "keyDerivationFunc.parameters", - &params_start, &params_end); + "keyDerivationFunc.parameters", + &params_start, &params_end); if (result != ASN1_SUCCESS) { MHD_gnutls_assert (); @@ -634,8 +641,8 @@ read_pbkdf2_params (ASN1_TYPE pbes2_asn, */ if ((result = MHD__asn1_create_element (MHD__gnutls_get_pkix (), - "PKIX1.pkcs-5-PBKDF2-params", - &pbkdf2_asn)) != ASN1_SUCCESS) + "PKIX1.pkcs-5-PBKDF2-params", + &pbkdf2_asn)) != ASN1_SUCCESS) { MHD_gnutls_assert (); return MHD_gtls_asn2err (result); @@ -643,7 +650,7 @@ read_pbkdf2_params (ASN1_TYPE pbes2_asn, result = MHD__asn1_der_decoding (&pbkdf2_asn, &der->data[params_start], - params_len, NULL); + params_len, NULL); if (result != ASN1_SUCCESS) { MHD_gnutls_assert (); @@ -655,7 +662,7 @@ read_pbkdf2_params (ASN1_TYPE pbes2_asn, params->salt_size = sizeof (params->salt); result = MHD__asn1_read_value (pbkdf2_asn, "salt.specified", params->salt, - &params->salt_size); + &params->salt_size); if (result != ASN1_SUCCESS) { MHD_gnutls_assert (); @@ -668,7 +675,7 @@ read_pbkdf2_params (ASN1_TYPE pbes2_asn, */ result = MHD__gnutls_x509_read_uint (pbkdf2_asn, "iterationCount", - &params->iter_count); + &params->iter_count); if (result != ASN1_SUCCESS) { MHD_gnutls_assert (); @@ -709,7 +716,8 @@ readMHD_pkcs12_kdf_params (ASN1_TYPE pbes2_asn, struct pbkdf2_params *params) /* read the salt */ params->salt_size = sizeof (params->salt); result = - MHD__asn1_read_value (pbes2_asn, "salt", params->salt, &params->salt_size); + MHD__asn1_read_value (pbes2_asn, "salt", params->salt, + &params->salt_size); if (result != ASN1_SUCCESS) { MHD_gnutls_assert (); @@ -794,8 +802,8 @@ read_pbe_enc_params (ASN1_TYPE pbes2_asn, result = MHD__asn1_der_decoding_startEnd (pbes2_asn, der->data, der->size, - "encryptionScheme.parameters", - &params_start, &params_end); + "encryptionScheme.parameters", + &params_start, &params_end); if (result != ASN1_SUCCESS) { MHD_gnutls_assert (); @@ -807,15 +815,16 @@ read_pbe_enc_params (ASN1_TYPE pbes2_asn, */ if ((result = MHD__asn1_create_element (MHD__gnutls_get_pkix (), - "PKIX1.pkcs-5-des-EDE3-CBC-params", - &pbe_asn)) != ASN1_SUCCESS) + "PKIX1.pkcs-5-des-EDE3-CBC-params", + &pbe_asn)) != ASN1_SUCCESS) { MHD_gnutls_assert (); return MHD_gtls_asn2err (result); } result = - MHD__asn1_der_decoding (&pbe_asn, &der->data[params_start], params_len, NULL); + MHD__asn1_der_decoding (&pbe_asn, &der->data[params_start], params_len, + NULL); if (result != ASN1_SUCCESS) { MHD_gnutls_assert (); @@ -899,9 +908,10 @@ decrypt_data (schema_id schema, ASN1_TYPE pkcs8_asn, if (schema == PBES2) { result = MHD_gc_pbkdf2_sha1 (password, strlen (password), - (const char*) kdf_params->salt, kdf_params->salt_size, - kdf_params->iter_count, - (char*) key, key_size); + (const char *) kdf_params->salt, + kdf_params->salt_size, + kdf_params->iter_count, (char *) key, + key_size); if (result != GC_OK) { @@ -914,9 +924,9 @@ decrypt_data (schema_id schema, ASN1_TYPE pkcs8_asn, { result = MHD_pkcs12_string_to_key (1 /*KEY*/, kdf_params->salt, - kdf_params->salt_size, - kdf_params->iter_count, password, - key_size, key); + kdf_params->salt_size, + kdf_params->iter_count, password, + key_size, key); if (result < 0) { diff --git a/src/daemon/https/x509/rfc2818_hostname.c b/src/daemon/https/x509/rfc2818_hostname.c @@ -84,7 +84,8 @@ MHD__gnutls_hostname_compare (const char *certname, const char *hostname) * Returns non zero for a successful match, and zero on failure. **/ int -MHD_gnutls_x509_crt_check_hostname (MHD_gnutls_x509_crt_t cert, const char *hostname) +MHD_gnutls_x509_crt_check_hostname (MHD_gnutls_x509_crt_t cert, + const char *hostname) { char dnsname[MAX_CN]; @@ -112,8 +113,8 @@ MHD_gnutls_x509_crt_check_hostname (MHD_gnutls_x509_crt_t cert, const char *host dnsnamesize = sizeof (dnsname); ret = MHD_gnutls_x509_crt_get_subject_alt_name (cert, i, - dnsname, &dnsnamesize, - NULL); + dnsname, &dnsnamesize, + NULL); if (ret == GNUTLS_SAN_DNSNAME) { @@ -141,7 +142,7 @@ MHD_gnutls_x509_crt_check_hostname (MHD_gnutls_x509_crt_t cert, const char *host */ dnsnamesize = sizeof (dnsname); if (MHD_gnutls_x509_crt_get_dn_by_oid (cert, OID_X520_COMMON_NAME, 0, - 0, dnsname, &dnsnamesize) < 0) + 0, dnsname, &dnsnamesize) < 0) { /* got an error, can't find a name */ diff --git a/src/daemon/https/x509/sign.c b/src/daemon/https/x509/sign.c @@ -50,7 +50,8 @@ */ static int encode_ber_digest_info (enum MHD_GNUTLS_HashAlgorithm hash, - const MHD_gnutls_datum_t * digest, MHD_gnutls_datum_t * info) + const MHD_gnutls_datum_t * digest, + MHD_gnutls_datum_t * info) { ASN1_TYPE dinfo = ASN1_TYPE_EMPTY; int result; @@ -65,14 +66,15 @@ encode_ber_digest_info (enum MHD_GNUTLS_HashAlgorithm hash, } if ((result = MHD__asn1_create_element (MHD__gnutls_getMHD__gnutls_asn (), - "GNUTLS.DigestInfo", - &dinfo)) != ASN1_SUCCESS) + "GNUTLS.DigestInfo", + &dinfo)) != ASN1_SUCCESS) { MHD_gnutls_assert (); return MHD_gtls_asn2err (result); } - result = MHD__asn1_write_value (dinfo, "digestAlgorithm.algorithm", algo, 1); + result = + MHD__asn1_write_value (dinfo, "digestAlgorithm.algorithm", algo, 1); if (result != ASN1_SUCCESS) { MHD_gnutls_assert (); @@ -86,7 +88,7 @@ encode_ber_digest_info (enum MHD_GNUTLS_HashAlgorithm hash, Regardless of what is correct, this appears to be what most implementations do. */ result = MHD__asn1_write_value (dinfo, "digestAlgorithm.parameters", - "\x05\x00", 2); + "\x05\x00", 2); if (result != ASN1_SUCCESS) { MHD_gnutls_assert (); @@ -94,7 +96,8 @@ encode_ber_digest_info (enum MHD_GNUTLS_HashAlgorithm hash, return MHD_gtls_asn2err (result); } - result = MHD__asn1_write_value (dinfo, "digest", digest->data, digest->size); + result = + MHD__asn1_write_value (dinfo, "digest", digest->data, digest->size); if (result != ASN1_SUCCESS) { MHD_gnutls_assert (); @@ -103,7 +106,7 @@ encode_ber_digest_info (enum MHD_GNUTLS_HashAlgorithm hash, } info->size = 0; - MHD__asn1_der_coding (dinfo, "", NULL, (int*) &info->size, NULL); + MHD__asn1_der_coding (dinfo, "", NULL, (int *) &info->size, NULL); info->data = MHD_gnutls_malloc (info->size); if (info->data == NULL) @@ -113,7 +116,8 @@ encode_ber_digest_info (enum MHD_GNUTLS_HashAlgorithm hash, return GNUTLS_E_MEMORY_ERROR; } - result = MHD__asn1_der_coding (dinfo, "", info->data, (int*) &info->size, NULL); + result = + MHD__asn1_der_coding (dinfo, "", info->data, (int *) &info->size, NULL); if (result != ASN1_SUCCESS) { MHD_gnutls_assert (); @@ -133,8 +137,8 @@ encode_ber_digest_info (enum MHD_GNUTLS_HashAlgorithm hash, */ static int pkcs1_rsa_sign (enum MHD_GNUTLS_HashAlgorithm hash, - const MHD_gnutls_datum_t * text, mpi_t * params, int params_len, - MHD_gnutls_datum_t * signature) + const MHD_gnutls_datum_t * text, mpi_t * params, + int params_len, MHD_gnutls_datum_t * signature) { int ret; opaque _digest[MAX_HASH_SIZE]; @@ -187,8 +191,9 @@ pkcs1_rsa_sign (enum MHD_GNUTLS_HashAlgorithm hash, */ static int MHD__gnutls_x509_sign (const MHD_gnutls_datum_t * tbs, - enum MHD_GNUTLS_HashAlgorithm hash, - MHD_gnutls_x509_privkey_t signer, MHD_gnutls_datum_t * signature) + enum MHD_GNUTLS_HashAlgorithm hash, + MHD_gnutls_x509_privkey_t signer, + MHD_gnutls_datum_t * signature) { int ret; @@ -218,9 +223,9 @@ MHD__gnutls_x509_sign (const MHD_gnutls_datum_t * tbs, */ int MHD__gnutls_x509_sign_tbs (ASN1_TYPE cert, const char *tbs_name, - enum MHD_GNUTLS_HashAlgorithm hash, - MHD_gnutls_x509_privkey_t signer, - MHD_gnutls_datum_t * signature) + enum MHD_GNUTLS_HashAlgorithm hash, + MHD_gnutls_x509_privkey_t signer, + MHD_gnutls_datum_t * signature) { int result; opaque *buf; diff --git a/src/daemon/https/x509/sign.h b/src/daemon/https/x509/sign.h @@ -23,6 +23,6 @@ */ int MHD__gnutls_x509_sign_tbs (ASN1_TYPE cert, const char *tbs_name, - enum MHD_GNUTLS_HashAlgorithm hash, - MHD_gnutls_x509_privkey_t signer, - MHD_gnutls_datum_t * signature); + enum MHD_GNUTLS_HashAlgorithm hash, + MHD_gnutls_x509_privkey_t signer, + MHD_gnutls_datum_t * signature); diff --git a/src/daemon/https/x509/verify.h b/src/daemon/https/x509/verify.h @@ -25,10 +25,12 @@ #include "x509.h" int MHD_gnutls_x509_crt_is_issuer (MHD_gnutls_x509_crt_t cert, - MHD_gnutls_x509_crt_t issuer); -int MHD__gnutls_x509_verify_signature (const MHD_gnutls_datum_t * tbs, - const MHD_gnutls_datum_t * signature, MHD_gnutls_x509_crt_t issuer); +int MHD__gnutls_x509_verify_signature (const MHD_gnutls_datum_t * tbs, + const MHD_gnutls_datum_t * signature, + MHD_gnutls_x509_crt_t issuer); int MHD__gnutls_x509_privkey_verify_signature (const MHD_gnutls_datum_t * tbs, - const MHD_gnutls_datum_t * signature, - MHD_gnutls_x509_privkey_t issuer); + const MHD_gnutls_datum_t * + signature, + MHD_gnutls_x509_privkey_t + issuer); diff --git a/src/daemon/https/x509/x509.c b/src/daemon/https/x509/x509.c @@ -51,14 +51,15 @@ int MHD_gnutls_x509_crt_init (MHD_gnutls_x509_crt_t * cert) { - MHD_gnutls_x509_crt_t tmp = MHD_gnutls_calloc (1, sizeof (MHD_gnutls_x509_crt_int)); + MHD_gnutls_x509_crt_t tmp = + MHD_gnutls_calloc (1, sizeof (MHD_gnutls_x509_crt_int)); int result; if (!tmp) return GNUTLS_E_MEMORY_ERROR; result = MHD__asn1_create_element (MHD__gnutls_get_pkix (), - "PKIX1.Certificate", &tmp->cert); + "PKIX1.Certificate", &tmp->cert); if (result != ASN1_SUCCESS) { MHD_gnutls_assert (); @@ -107,8 +108,8 @@ MHD_gnutls_x509_crt_deinit (MHD_gnutls_x509_crt_t cert) **/ int MHD_gnutls_x509_crt_import (MHD_gnutls_x509_crt_t cert, - const MHD_gnutls_datum_t * data, - MHD_gnutls_x509_crt_fmt_t format) + const MHD_gnutls_datum_t * data, + MHD_gnutls_x509_crt_fmt_t format) { int result = 0, need_free = 0; MHD_gnutls_datum_t _data; @@ -130,14 +131,15 @@ MHD_gnutls_x509_crt_import (MHD_gnutls_x509_crt_t cert, opaque *out; /* Try the first header */ - result = MHD__gnutls_fbase64_decode (PEM_X509_CERT2, data->data, data->size, - &out); + result = + MHD__gnutls_fbase64_decode (PEM_X509_CERT2, data->data, data->size, + &out); if (result <= 0) { /* try for the second header */ result = MHD__gnutls_fbase64_decode (PEM_X509_CERT, data->data, - data->size, &out); + data->size, &out); if (result <= 0) { @@ -205,10 +207,10 @@ cleanup:MHD_gnutls_free (signature); **/ int MHD_gnutls_x509_crt_get_dn_by_oid (MHD_gnutls_x509_crt_t cert, - const char *oid, - int indx, - unsigned int raw_flag, - void *buf, size_t * sizeof_buf) + const char *oid, + int indx, + unsigned int raw_flag, + void *buf, size_t * sizeof_buf) { if (cert == NULL) { @@ -217,8 +219,8 @@ MHD_gnutls_x509_crt_get_dn_by_oid (MHD_gnutls_x509_crt_t cert, } return MHD__gnutls_x509_parse_dn_oid (cert->cert, - "tbsCertificate.subject.rdnSequence", oid, - indx, raw_flag, buf, sizeof_buf); + "tbsCertificate.subject.rdnSequence", + oid, indx, raw_flag, buf, sizeof_buf); } /** @@ -247,8 +249,8 @@ MHD_gnutls_x509_crt_get_signature_algorithm (MHD_gnutls_x509_crt_t cert) * read. They will be read from the issuer's certificate if needed. */ result = - MHD__gnutls_x509_read_value (cert->cert, "signatureAlgorithm.algorithm", &sa, - 0); + MHD__gnutls_x509_read_value (cert->cert, "signatureAlgorithm.algorithm", + &sa, 0); if (result < 0) { @@ -256,7 +258,7 @@ MHD_gnutls_x509_crt_get_signature_algorithm (MHD_gnutls_x509_crt_t cert) return result; } - result = MHD_gtls_x509_oid2sign_algorithm ((const char*) sa.data); + result = MHD_gtls_x509_oid2sign_algorithm ((const char *) sa.data); MHD__gnutls_free_datum (&sa); @@ -275,7 +277,7 @@ MHD_gnutls_x509_crt_get_signature_algorithm (MHD_gnutls_x509_crt_t cert) **/ int MHD_gnutls_x509_crt_get_signature (MHD_gnutls_x509_crt_t cert, - char *sig, size_t * sizeof_sig) + char *sig, size_t * sizeof_sig) { int result; int bits, len; @@ -342,7 +344,7 @@ MHD_gnutls_x509_crt_get_version (MHD_gnutls_x509_crt_t cert) len = sizeof (version); if ((result = MHD__asn1_read_value (cert->cert, "tbsCertificate.version", version, - &len)) != ASN1_SUCCESS) + &len)) != ASN1_SUCCESS) { if (result == ASN1_ELEMENT_NOT_FOUND) @@ -373,7 +375,7 @@ MHD_gnutls_x509_crt_get_activation_time (MHD_gnutls_x509_crt_t cert) } return MHD__gnutls_x509_get_time (cert->cert, - "tbsCertificate.validity.notBefore"); + "tbsCertificate.validity.notBefore"); } /** @@ -395,7 +397,7 @@ MHD_gnutls_x509_crt_get_expiration_time (MHD_gnutls_x509_crt_t cert) } return MHD__gnutls_x509_get_time (cert->cert, - "tbsCertificate.validity.notAfter"); + "tbsCertificate.validity.notAfter"); } /** @@ -415,7 +417,7 @@ MHD_gnutls_x509_crt_get_expiration_time (MHD_gnutls_x509_crt_t cert) **/ int MHD_gnutls_x509_crt_get_serial (MHD_gnutls_x509_crt_t cert, - void *result, size_t * result_size) + void *result, size_t * result_size) { int ret, len; @@ -428,7 +430,8 @@ MHD_gnutls_x509_crt_get_serial (MHD_gnutls_x509_crt_t cert, len = *result_size; ret = - MHD__asn1_read_value (cert->cert, "tbsCertificate.serialNumber", result, &len); + MHD__asn1_read_value (cert->cert, "tbsCertificate.serialNumber", result, + &len); *result_size = len; if (ret != ASN1_SUCCESS) @@ -459,7 +462,8 @@ MHD_gnutls_x509_crt_get_serial (MHD_gnutls_x509_crt_t cert, * **/ int -MHD_gnutls_x509_crt_get_pk_algorithm (MHD_gnutls_x509_crt_t cert, unsigned int *bits) +MHD_gnutls_x509_crt_get_pk_algorithm (MHD_gnutls_x509_crt_t cert, + unsigned int *bits) { int result; @@ -470,8 +474,8 @@ MHD_gnutls_x509_crt_get_pk_algorithm (MHD_gnutls_x509_crt_t cert, unsigned int * } result = MHD__gnutls_x509_get_pk_algorithm (cert->cert, - "tbsCertificate.subjectPublicKeyInfo", - bits); + "tbsCertificate.subjectPublicKeyInfo", + bits); if (result < 0) { @@ -533,7 +537,7 @@ parse_general_name (ASN1_TYPE src, return MHD_gtls_asn2err (result); } - type = MHD__gnutls_x509_san_find_type ((char*) choice_type); + type = MHD__gnutls_x509_san_find_type ((char *) choice_type); if (type == (MHD_gnutls_x509_subject_alt_name_t) - 1) { MHD_gnutls_assert (); @@ -591,8 +595,8 @@ parse_general_name (ASN1_TYPE src, ASN1_TYPE c2 = ASN1_TYPE_EMPTY; result = - MHD__asn1_create_element (MHD__gnutls_get_pkix (), "PKIX1.XmppAddr", - &c2); + MHD__asn1_create_element (MHD__gnutls_get_pkix (), + "PKIX1.XmppAddr", &c2); if (result != ASN1_SUCCESS) { MHD_gnutls_assert (); @@ -636,7 +640,7 @@ parse_general_name (ASN1_TYPE src, size_t orig_name_size = *name_size; MHD_gtls_str_cat (nptr, sizeof (nptr), "."); - MHD_gtls_str_cat (nptr, sizeof (nptr), (const char*) choice_type); + MHD_gtls_str_cat (nptr, sizeof (nptr), (const char *) choice_type); len = *name_size; result = MHD__asn1_read_value (src, nptr, name, &len); @@ -700,7 +704,7 @@ get_subject_alt_name (MHD_gnutls_x509_crt_t cert, if ((result = MHD__gnutls_x509_crt_get_extension (cert, "2.5.29.17", 0, &dnsname, - critical)) < 0) + critical)) < 0) { return result; } @@ -712,7 +716,8 @@ get_subject_alt_name (MHD_gnutls_x509_crt_t cert, } result = - MHD__asn1_create_element (MHD__gnutls_get_pkix (), "PKIX1.SubjectAltName", &c2); + MHD__asn1_create_element (MHD__gnutls_get_pkix (), "PKIX1.SubjectAltName", + &c2); if (result != ASN1_SUCCESS) { MHD_gnutls_assert (); @@ -781,10 +786,10 @@ get_subject_alt_name (MHD_gnutls_x509_crt_t cert, **/ int MHD_gnutls_x509_crt_get_subject_alt_name (MHD_gnutls_x509_crt_t cert, - unsigned int seq, - void *ret, - size_t * ret_size, - unsigned int *critical) + unsigned int seq, + void *ret, + size_t * ret_size, + unsigned int *critical) { return get_subject_alt_name (cert, seq, ret, ret_size, NULL, critical, 0); } @@ -811,8 +816,8 @@ MHD_gnutls_x509_crt_get_subject_alt_name (MHD_gnutls_x509_crt_t cert, **/ static int MHD_gnutls_x509_crt_get_basic_constraints (MHD_gnutls_x509_crt_t cert, - unsigned int *critical, - int *ca, int *pathlen) + unsigned int *critical, + int *ca, int *pathlen) { int result; MHD_gnutls_datum_t basicConstraints; @@ -825,8 +830,8 @@ MHD_gnutls_x509_crt_get_basic_constraints (MHD_gnutls_x509_crt_t cert, } if ((result = MHD__gnutls_x509_crt_get_extension (cert, "2.5.29.19", 0, - &basicConstraints, critical)) - < 0) + &basicConstraints, + critical)) < 0) { return result; } @@ -838,8 +843,10 @@ MHD_gnutls_x509_crt_get_basic_constraints (MHD_gnutls_x509_crt_t cert, } result = MHD__gnutls_x509_ext_extract_basicConstraints (&tmp_ca, pathlen, - basicConstraints.data, - basicConstraints.size); + basicConstraints. + data, + basicConstraints. + size); if (ca) *ca = tmp_ca; MHD__gnutls_free_datum (&basicConstraints); @@ -872,11 +879,12 @@ MHD_gnutls_x509_crt_get_basic_constraints (MHD_gnutls_x509_crt_t cert, * **/ int -MHD_gnutls_x509_crt_get_ca_status (MHD_gnutls_x509_crt_t cert, unsigned int *critical) +MHD_gnutls_x509_crt_get_ca_status (MHD_gnutls_x509_crt_t cert, + unsigned int *critical) { int ca, pathlen; return MHD_gnutls_x509_crt_get_basic_constraints (cert, critical, &ca, - &pathlen); + &pathlen); } /** @@ -900,8 +908,8 @@ MHD_gnutls_x509_crt_get_ca_status (MHD_gnutls_x509_crt_t cert, unsigned int *cri **/ int MHD_gnutls_x509_crt_get_key_usage (MHD_gnutls_x509_crt_t cert, - unsigned int *key_usage, - unsigned int *critical) + unsigned int *key_usage, + unsigned int *critical) { int result; MHD_gnutls_datum_t keyUsage; @@ -915,7 +923,7 @@ MHD_gnutls_x509_crt_get_key_usage (MHD_gnutls_x509_crt_t cert, if ((result = MHD__gnutls_x509_crt_get_extension (cert, "2.5.29.15", 0, &keyUsage, - critical)) < 0) + critical)) < 0) { return result; } @@ -927,7 +935,7 @@ MHD_gnutls_x509_crt_get_key_usage (MHD_gnutls_x509_crt_t cert, } result = MHD__gnutls_x509_ext_extract_keyUsage (&_usage, keyUsage.data, - keyUsage.size); + keyUsage.size); MHD__gnutls_free_datum (&keyUsage); *key_usage = _usage; @@ -944,7 +952,8 @@ MHD_gnutls_x509_crt_get_key_usage (MHD_gnutls_x509_crt_t cert, static int MHD__gnutls_x509_crt_get_raw_dn2 (MHD_gnutls_x509_crt_t cert, - const char *whom, MHD_gnutls_datum_t * start) + const char *whom, + MHD_gnutls_datum_t * start) { ASN1_TYPE c2 = ASN1_TYPE_EMPTY; int result, len1; @@ -956,22 +965,24 @@ MHD__gnutls_x509_crt_get_raw_dn2 (MHD_gnutls_x509_crt_t cert, /* get the issuer of 'cert' */ if ((result = - MHD__asn1_create_element (MHD__gnutls_get_pkix (), "PKIX1.TBSCertificate", - &c2)) != ASN1_SUCCESS) + MHD__asn1_create_element (MHD__gnutls_get_pkix (), + "PKIX1.TBSCertificate", + &c2)) != ASN1_SUCCESS) { MHD_gnutls_assert (); return MHD_gtls_asn2err (result); } result = MHD__gnutls_x509_get_signed_data (cert->cert, "tbsCertificate", - &signed_data); + &signed_data); if (result < 0) { MHD_gnutls_assert (); goto cleanup; } - result = MHD__asn1_der_decoding (&c2, signed_data.data, signed_data.size, NULL); + result = + MHD__asn1_der_decoding (&c2, signed_data.data, signed_data.size, NULL); if (result != ASN1_SUCCESS) { MHD_gnutls_assert (); @@ -980,8 +991,9 @@ MHD__gnutls_x509_crt_get_raw_dn2 (MHD_gnutls_x509_crt_t cert, goto cleanup; } - result = MHD__asn1_der_decoding_startEnd (c2, signed_data.data, signed_data.size, - whom, &start1, &end1); + result = + MHD__asn1_der_decoding_startEnd (c2, signed_data.data, signed_data.size, + whom, &start1, &end1); if (result != ASN1_SUCCESS) { @@ -1014,7 +1026,7 @@ cleanup:MHD__asn1_delete_structure (&c2); **/ int MHD_gnutls_x509_crt_get_raw_issuer_dn (MHD_gnutls_x509_crt_t cert, - MHD_gnutls_datum_t * start) + MHD_gnutls_datum_t * start) { return MHD__gnutls_x509_crt_get_raw_dn2 (cert, "issuer", start); } @@ -1031,13 +1043,15 @@ MHD_gnutls_x509_crt_get_raw_issuer_dn (MHD_gnutls_x509_crt_t cert, * **/ int -MHD_gnutls_x509_crt_get_raw_dn (MHD_gnutls_x509_crt_t cert, MHD_gnutls_datum_t * start) +MHD_gnutls_x509_crt_get_raw_dn (MHD_gnutls_x509_crt_t cert, + MHD_gnutls_datum_t * start) { return MHD__gnutls_x509_crt_get_raw_dn2 (cert, "subject", start); } static int -get_dn (MHD_gnutls_x509_crt_t cert, const char *whom, MHD_gnutls_x509_dn_t * dn) +get_dn (MHD_gnutls_x509_crt_t cert, const char *whom, + MHD_gnutls_x509_dn_t * dn) { *dn = MHD__asn1_find_node (cert->cert, whom); if (!*dn) @@ -1056,7 +1070,8 @@ get_dn (MHD_gnutls_x509_crt_t cert, const char *whom, MHD_gnutls_x509_dn_t * dn) * Returns: Returns 0 on success, or an error code. **/ int -MHD_gnutls_x509_crt_get_subject (MHD_gnutls_x509_crt_t cert, MHD_gnutls_x509_dn_t * dn) +MHD_gnutls_x509_crt_get_subject (MHD_gnutls_x509_crt_t cert, + MHD_gnutls_x509_dn_t * dn) { return get_dn (cert, "tbsCertificate.subject.rdnSequence", dn); } @@ -1083,8 +1098,8 @@ MHD_gnutls_x509_crt_get_subject (MHD_gnutls_x509_crt_t cert, MHD_gnutls_x509_dn_ **/ int MHD_gnutls_x509_crt_export (MHD_gnutls_x509_crt_t cert, - MHD_gnutls_x509_crt_fmt_t format, - void *output_data, size_t * output_data_size) + MHD_gnutls_x509_crt_fmt_t format, + void *output_data, size_t * output_data_size) { if (cert == NULL) { @@ -1093,7 +1108,7 @@ MHD_gnutls_x509_crt_export (MHD_gnutls_x509_crt_t cert, } return MHD__gnutls_x509_export_int (cert->cert, format, "CERTIFICATE", - output_data, output_data_size); + output_data, output_data_size); } #ifdef ENABLE_PKI @@ -1112,8 +1127,8 @@ MHD_gnutls_x509_crt_export (MHD_gnutls_x509_crt_t cert, **/ int MHD_gnutls_x509_crt_check_revocation (MHD_gnutls_x509_crt_t cert, - const MHD_gnutls_x509_crl_t * crl_list, - int crl_list_length) + const MHD_gnutls_x509_crl_t * crl_list, + int crl_list_length) { opaque serial[64]; opaque cert_serial[64]; @@ -1160,7 +1175,8 @@ MHD_gnutls_x509_crt_check_revocation (MHD_gnutls_x509_crt_t cert, /* Step 2. Read the certificate's serial number */ cert_serial_size = sizeof (cert_serial); - ret = MHD_gnutls_x509_crt_get_serial (cert, cert_serial, &cert_serial_size); + ret = + MHD_gnutls_x509_crt_get_serial (cert, cert_serial, &cert_serial_size); if (ret < 0) { MHD_gnutls_assert (); @@ -1182,7 +1198,7 @@ MHD_gnutls_x509_crt_check_revocation (MHD_gnutls_x509_crt_t cert, { serial_size = sizeof (serial); ret = MHD_gnutls_x509_crl_get_crt_serial (crl_list[j], i, serial, - &serial_size, NULL); + &serial_size, NULL); if (ret < 0) { @@ -1205,4 +1221,3 @@ MHD_gnutls_x509_crt_check_revocation (MHD_gnutls_x509_crt_t cert, } #endif - diff --git a/src/daemon/https/x509/x509.h b/src/daemon/https/x509/x509.h @@ -90,17 +90,19 @@ extern "C" int MHD_gnutls_x509_crt_init (MHD_gnutls_x509_crt_t * cert); void MHD_gnutls_x509_crt_deinit (MHD_gnutls_x509_crt_t cert); int MHD_gnutls_x509_crt_import (MHD_gnutls_x509_crt_t cert, - const MHD_gnutls_datum_t * data, - MHD_gnutls_x509_crt_fmt_t format); + const MHD_gnutls_datum_t * data, + MHD_gnutls_x509_crt_fmt_t format); int MHD_gnutls_x509_crt_export (MHD_gnutls_x509_crt_t cert, - MHD_gnutls_x509_crt_fmt_t format, - void *output_data, size_t * output_data_size); + MHD_gnutls_x509_crt_fmt_t format, + void *output_data, + size_t * output_data_size); int MHD_gnutls_x509_crt_check_hostname (MHD_gnutls_x509_crt_t cert, - const char *hostname); + const char *hostname); - int MHD_gnutls_x509_crt_get_signature_algorithm (MHD_gnutls_x509_crt_t cert); + int MHD_gnutls_x509_crt_get_signature_algorithm (MHD_gnutls_x509_crt_t + cert); int MHD_gnutls_x509_crt_get_signature (MHD_gnutls_x509_crt_t cert, - char *sig, size_t * sizeof_sig); + char *sig, size_t * sizeof_sig); int MHD_gnutls_x509_crt_get_version (MHD_gnutls_x509_crt_t cert); #define GNUTLS_CRL_REASON_UNUSED 128 @@ -116,86 +118,90 @@ extern "C" time_t MHD_gnutls_x509_crt_get_activation_time (MHD_gnutls_x509_crt_t cert); time_t MHD_gnutls_x509_crt_get_expiration_time (MHD_gnutls_x509_crt_t cert); int MHD_gnutls_x509_crt_get_serial (MHD_gnutls_x509_crt_t cert, - void *result, size_t * result_size); + void *result, size_t * result_size); int MHD_gnutls_x509_crt_get_pk_algorithm (MHD_gnutls_x509_crt_t cert, - unsigned int *bits); + unsigned int *bits); int MHD_gnutls_x509_crt_get_subject_alt_name (MHD_gnutls_x509_crt_t cert, - unsigned int seq, - void *ret, - size_t * ret_size, - unsigned int *critical); + unsigned int seq, + void *ret, + size_t * ret_size, + unsigned int *critical); int MHD_gnutls_x509_crt_get_ca_status (MHD_gnutls_x509_crt_t cert, - unsigned int *critical); + unsigned int *critical); /* The key_usage flags are defined in gnutls.h. They are the * GNUTLS_KEY_* definitions. */ int MHD_gnutls_x509_crt_get_key_usage (MHD_gnutls_x509_crt_t cert, - unsigned int *key_usage, - unsigned int *critical); + unsigned int *key_usage, + unsigned int *critical); int MHD_gnutls_x509_crt_set_key_usage (MHD_gnutls_x509_crt_t crt, - unsigned int usage); + unsigned int usage); int MHD_gnutls_x509_dn_oid_known (const char *oid); /* Read extensions by sequence number. */ int MHD_gnutls_x509_crt_set_extension_by_oid (MHD_gnutls_x509_crt_t crt, - const char *oid, - const void *buf, - size_t sizeof_buf, - unsigned int critical); + const char *oid, + const void *buf, + size_t sizeof_buf, + unsigned int critical); /* X.509 Certificate writing. */ int MHD_gnutls_x509_crt_set_dn_by_oid (MHD_gnutls_x509_crt_t crt, - const char *oid, - unsigned int raw_flag, - const void *name, - unsigned int sizeof_name); + const char *oid, + unsigned int raw_flag, + const void *name, + unsigned int sizeof_name); int MHD_gnutls_x509_crt_set_issuer_dn_by_oid (MHD_gnutls_x509_crt_t crt, - const char *oid, - unsigned int raw_flag, - const void *name, - unsigned int sizeof_name); + const char *oid, + unsigned int raw_flag, + const void *name, + unsigned int sizeof_name); int MHD_gnutls_x509_crt_set_version (MHD_gnutls_x509_crt_t crt, - unsigned int version); + unsigned int version); int MHD_gnutls_x509_crt_set_key (MHD_gnutls_x509_crt_t crt, - MHD_gnutls_x509_privkey_t key); - int MHD_gnutls_x509_crt_set_ca_status (MHD_gnutls_x509_crt_t crt, unsigned int ca); + MHD_gnutls_x509_privkey_t key); + int MHD_gnutls_x509_crt_set_ca_status (MHD_gnutls_x509_crt_t crt, + unsigned int ca); int MHD_gnutls_x509_crt_set_basic_constraints (MHD_gnutls_x509_crt_t crt, - unsigned int ca, - int pathLenConstraint); - int MHD_gnutls_x509_crt_set_subject_alternative_name (MHD_gnutls_x509_crt_t crt, - MHD_gnutls_x509_subject_alt_name_t - type, - const char *data_string); + unsigned int ca, + int pathLenConstraint); + int MHD_gnutls_x509_crt_set_subject_alternative_name (MHD_gnutls_x509_crt_t + crt, + MHD_gnutls_x509_subject_alt_name_t + type, + const char + *data_string); int MHD_gnutls_x509_crt_sign (MHD_gnutls_x509_crt_t crt, - MHD_gnutls_x509_crt_t issuer, - MHD_gnutls_x509_privkey_t issuer_key); + MHD_gnutls_x509_crt_t issuer, + MHD_gnutls_x509_privkey_t issuer_key); int MHD_gnutls_x509_crt_sign2 (MHD_gnutls_x509_crt_t crt, - MHD_gnutls_x509_crt_t issuer, - MHD_gnutls_x509_privkey_t issuer_key, - enum MHD_GNUTLS_HashAlgorithm, - unsigned int flags); + MHD_gnutls_x509_crt_t issuer, + MHD_gnutls_x509_privkey_t issuer_key, + enum MHD_GNUTLS_HashAlgorithm, + unsigned int flags); int MHD_gnutls_x509_crt_set_activation_time (MHD_gnutls_x509_crt_t cert, - time_t act_time); + time_t act_time); int MHD_gnutls_x509_crt_set_expiration_time (MHD_gnutls_x509_crt_t cert, - time_t exp_time); + time_t exp_time); int MHD_gnutls_x509_crt_set_serial (MHD_gnutls_x509_crt_t cert, - const void *serial, size_t serial_size); + const void *serial, size_t serial_size); int MHD_gnutls_x509_crt_set_subject_key_id (MHD_gnutls_x509_crt_t cert, - const void *id, size_t id_size); + const void *id, size_t id_size); int MHD_gnutls_x509_crt_set_proxy_dn (MHD_gnutls_x509_crt_t crt, - MHD_gnutls_x509_crt_t eecrt, - unsigned int raw_flag, - const void *name, - unsigned int sizeof_name); + MHD_gnutls_x509_crt_t eecrt, + unsigned int raw_flag, + const void *name, + unsigned int sizeof_name); int MHD_gnutls_x509_crt_set_proxy (MHD_gnutls_x509_crt_t crt, - int pathLenConstraint, - const char *policyLanguage, - const char *policy, size_t sizeof_policy); + int pathLenConstraint, + const char *policyLanguage, + const char *policy, + size_t sizeof_policy); typedef enum MHD_gnutls_certificate_print_formats { @@ -205,31 +211,31 @@ extern "C" } MHD_gnutls_certificate_print_formats_t; int MHD_gnutls_x509_crt_print (MHD_gnutls_x509_crt_t cert, - MHD_gnutls_certificate_print_formats_t format, - MHD_gnutls_datum_t * out); + MHD_gnutls_certificate_print_formats_t + format, MHD_gnutls_datum_t * out); int MHD_gnutls_x509_crl_print (MHD_gnutls_x509_crl_t crl, - MHD_gnutls_certificate_print_formats_t format, - MHD_gnutls_datum_t * out); + MHD_gnutls_certificate_print_formats_t + format, MHD_gnutls_datum_t * out); /* Access to internal Certificate fields. */ int MHD_gnutls_x509_crt_get_raw_issuer_dn (MHD_gnutls_x509_crt_t cert, - MHD_gnutls_datum_t * start); + MHD_gnutls_datum_t * start); int MHD_gnutls_x509_crt_get_raw_dn (MHD_gnutls_x509_crt_t cert, - MHD_gnutls_datum_t * start); + MHD_gnutls_datum_t * start); /* RDN handling. */ int MHD_gnutls_x509_rdn_get (const MHD_gnutls_datum_t * idn, - char *buf, size_t * sizeof_buf); + char *buf, size_t * sizeof_buf); int MHD_gnutls_x509_rdn_get_oid (const MHD_gnutls_datum_t * idn, - int indx, void *buf, size_t * sizeof_buf); + int indx, void *buf, size_t * sizeof_buf); int MHD_gnutls_x509_rdn_get_by_oid (const MHD_gnutls_datum_t * idn, - const char *oid, - int indx, - unsigned int raw_flag, - void *buf, size_t * sizeof_buf); + const char *oid, + int indx, + unsigned int raw_flag, + void *buf, size_t * sizeof_buf); typedef void *MHD_gnutls_x509_dn_t; @@ -241,30 +247,32 @@ extern "C" } MHD_gnutls_x509_ava_st; int MHD_gnutls_x509_crt_get_subject (MHD_gnutls_x509_crt_t cert, - MHD_gnutls_x509_dn_t * dn); + MHD_gnutls_x509_dn_t * dn); /* CRL handling functions. */ int MHD_gnutls_x509_crl_init (MHD_gnutls_x509_crl_t * crl); void MHD_gnutls_x509_crl_deinit (MHD_gnutls_x509_crl_t crl); int MHD_gnutls_x509_crl_import (MHD_gnutls_x509_crl_t crl, - const MHD_gnutls_datum_t * data, - MHD_gnutls_x509_crt_fmt_t format); + const MHD_gnutls_datum_t * data, + MHD_gnutls_x509_crt_fmt_t format); int MHD_gnutls_x509_crl_export (MHD_gnutls_x509_crl_t crl, - MHD_gnutls_x509_crt_fmt_t format, - void *output_data, size_t * output_data_size); + MHD_gnutls_x509_crt_fmt_t format, + void *output_data, + size_t * output_data_size); int MHD_gnutls_x509_crl_get_issuer_dn_by_oid (MHD_gnutls_x509_crl_t crl, - const char *oid, - int indx, - unsigned int raw_flag, - void *buf, size_t * sizeof_buf); - int MHD_gnutls_x509_crl_get_dn_oid (MHD_gnutls_x509_crl_t crl, - int indx, void *oid, size_t * sizeof_oid); + const char *oid, + int indx, + unsigned int raw_flag, + void *buf, + size_t * sizeof_buf); + int MHD_gnutls_x509_crl_get_dn_oid (MHD_gnutls_x509_crl_t crl, int indx, + void *oid, size_t * sizeof_oid); int MHD_gnutls_x509_crl_get_signature_algorithm (MHD_gnutls_x509_crl_t crl); int MHD_gnutls_x509_crl_get_signature (MHD_gnutls_x509_crl_t crl, - char *sig, size_t * sizeof_sig); + char *sig, size_t * sizeof_sig); int MHD_gnutls_x509_crl_get_version (MHD_gnutls_x509_crl_t crl); time_t MHD_gnutls_x509_crl_get_this_update (MHD_gnutls_x509_crl_t crl); @@ -272,37 +280,38 @@ extern "C" int MHD_gnutls_x509_crl_get_crt_count (MHD_gnutls_x509_crl_t crl); int MHD_gnutls_x509_crl_get_crt_serial (MHD_gnutls_x509_crl_t crl, - int indx, - unsigned char *serial, - size_t * serial_size, time_t * t); + int indx, + unsigned char *serial, + size_t * serial_size, time_t * t); #define MHD_gnutls_x509_crl_get_certificate_count MHD_gnutls_x509_crl_get_crt_count #define MHD_gnutls_x509_crl_get_certificate MHD_gnutls_x509_crl_get_crt_serial int MHD_gnutls_x509_crl_check_issuer (MHD_gnutls_x509_crl_t crl, - MHD_gnutls_x509_crt_t issuer); + MHD_gnutls_x509_crt_t issuer); /* CRL writing. */ int MHD_gnutls_x509_crl_set_version (MHD_gnutls_x509_crl_t crl, - unsigned int version); + unsigned int version); int MHD_gnutls_x509_crl_sign (MHD_gnutls_x509_crl_t crl, - MHD_gnutls_x509_crt_t issuer, - MHD_gnutls_x509_privkey_t issuer_key); + MHD_gnutls_x509_crt_t issuer, + MHD_gnutls_x509_privkey_t issuer_key); int MHD_gnutls_x509_crl_sign2 (MHD_gnutls_x509_crl_t crl, - MHD_gnutls_x509_crt_t issuer, - MHD_gnutls_x509_privkey_t issuer_key, - enum MHD_GNUTLS_HashAlgorithm, - unsigned int flags); + MHD_gnutls_x509_crt_t issuer, + MHD_gnutls_x509_privkey_t issuer_key, + enum MHD_GNUTLS_HashAlgorithm, + unsigned int flags); int MHD_gnutls_x509_crl_set_this_update (MHD_gnutls_x509_crl_t crl, - time_t act_time); + time_t act_time); int MHD_gnutls_x509_crl_set_next_update (MHD_gnutls_x509_crl_t crl, - time_t exp_time); + time_t exp_time); int MHD_gnutls_x509_crl_set_crt_serial (MHD_gnutls_x509_crl_t crl, - const void *serial, - size_t serial_size, - time_t revocation_time); + const void *serial, + size_t serial_size, + time_t revocation_time); int MHD_gnutls_x509_crl_set_crt (MHD_gnutls_x509_crl_t crl, - MHD_gnutls_x509_crt_t crt, time_t revocation_time); + MHD_gnutls_x509_crt_t crt, + time_t revocation_time); /* PKCS7 structures handling */ @@ -312,29 +321,32 @@ extern "C" int MHD_gnutls_pkcs7_init (MHD_gnutls_pkcs7_t * pkcs7); void MHD_gnutls_pkcs7_deinit (MHD_gnutls_pkcs7_t pkcs7); int MHD_gnutls_pkcs7_import (MHD_gnutls_pkcs7_t pkcs7, - const MHD_gnutls_datum_t * data, - MHD_gnutls_x509_crt_fmt_t format); + const MHD_gnutls_datum_t * data, + MHD_gnutls_x509_crt_fmt_t format); int MHD_gnutls_pkcs7_export (MHD_gnutls_pkcs7_t pkcs7, - MHD_gnutls_x509_crt_fmt_t format, - void *output_data, size_t * output_data_size); + MHD_gnutls_x509_crt_fmt_t format, + void *output_data, size_t * output_data_size); int MHD_gnutls_pkcs7_get_crt_count (MHD_gnutls_pkcs7_t pkcs7); int MHD_gnutls_pkcs7_get_crt_raw (MHD_gnutls_pkcs7_t pkcs7, - int indx, - void *certificate, size_t * certificate_size); + int indx, + void *certificate, + size_t * certificate_size); int MHD_gnutls_pkcs7_set_crt_raw (MHD_gnutls_pkcs7_t pkcs7, - const MHD_gnutls_datum_t * crt); - int MHD_gnutls_pkcs7_set_crt (MHD_gnutls_pkcs7_t pkcs7, MHD_gnutls_x509_crt_t crt); + const MHD_gnutls_datum_t * crt); + int MHD_gnutls_pkcs7_set_crt (MHD_gnutls_pkcs7_t pkcs7, + MHD_gnutls_x509_crt_t crt); int MHD_gnutls_pkcs7_delete_crt (MHD_gnutls_pkcs7_t pkcs7, int indx); int MHD_gnutls_pkcs7_get_crl_raw (MHD_gnutls_pkcs7_t pkcs7, - int indx, void *crl, size_t * crl_size); + int indx, void *crl, size_t * crl_size); int MHD_gnutls_pkcs7_get_crl_count (MHD_gnutls_pkcs7_t pkcs7); int MHD_gnutls_pkcs7_set_crl_raw (MHD_gnutls_pkcs7_t pkcs7, - const MHD_gnutls_datum_t * crt); - int MHD_gnutls_pkcs7_set_crl (MHD_gnutls_pkcs7_t pkcs7, MHD_gnutls_x509_crl_t crl); + const MHD_gnutls_datum_t * crt); + int MHD_gnutls_pkcs7_set_crl (MHD_gnutls_pkcs7_t pkcs7, + MHD_gnutls_x509_crl_t crl); int MHD_gnutls_pkcs7_delete_crl (MHD_gnutls_pkcs7_t pkcs7, int indx); /* X.509 Certificate verification functions. @@ -375,28 +387,29 @@ extern "C" } MHD_gnutls_certificate_verify_flags; int MHD_gnutls_x509_crt_check_issuer (MHD_gnutls_x509_crt_t cert, - MHD_gnutls_x509_crt_t issuer); - - int MHD_gnutls_x509_crt_list_verify (const MHD_gnutls_x509_crt_t * cert_list, - int cert_list_length, - const MHD_gnutls_x509_crt_t * CA_list, - int CA_list_length, - const MHD_gnutls_x509_crl_t * CRL_list, - int CRL_list_length, - unsigned int flags, unsigned int *verify); + MHD_gnutls_x509_crt_t issuer); + + int MHD_gnutls_x509_crt_list_verify (const MHD_gnutls_x509_crt_t * + cert_list, int cert_list_length, + const MHD_gnutls_x509_crt_t * CA_list, + int CA_list_length, + const MHD_gnutls_x509_crl_t * CRL_list, + int CRL_list_length, + unsigned int flags, + unsigned int *verify); int MHD_gnutls_x509_crt_verify (MHD_gnutls_x509_crt_t cert, - const MHD_gnutls_x509_crt_t * CA_list, - int CA_list_length, - unsigned int flags, unsigned int *verify); + const MHD_gnutls_x509_crt_t * CA_list, + int CA_list_length, + unsigned int flags, unsigned int *verify); int MHD_gnutls_x509_crl_verify (MHD_gnutls_x509_crl_t crl, - const MHD_gnutls_x509_crt_t * CA_list, - int CA_list_length, - unsigned int flags, unsigned int *verify); + const MHD_gnutls_x509_crt_t * CA_list, + int CA_list_length, + unsigned int flags, unsigned int *verify); int MHD_gnutls_x509_crt_check_revocation (MHD_gnutls_x509_crt_t cert, - const MHD_gnutls_x509_crl_t * - crl_list, int crl_list_length); + const MHD_gnutls_x509_crl_t * + crl_list, int crl_list_length); /* Flags for the MHD_gnutls_x509_privkey_export_pkcs8() function. @@ -420,62 +433,65 @@ extern "C" int MHD_gnutls_x509_privkey_init (MHD_gnutls_x509_privkey_t * key); void MHD_gnutls_x509_privkey_deinit (MHD_gnutls_x509_privkey_t key); int MHD_gnutls_x509_privkey_cpy (MHD_gnutls_x509_privkey_t dst, - MHD_gnutls_x509_privkey_t src); + MHD_gnutls_x509_privkey_t src); int MHD_gnutls_x509_privkey_import (MHD_gnutls_x509_privkey_t key, - const MHD_gnutls_datum_t * data, - MHD_gnutls_x509_crt_fmt_t format); + const MHD_gnutls_datum_t * data, + MHD_gnutls_x509_crt_fmt_t format); int MHD_gnutls_x509_privkey_import_pkcs8 (MHD_gnutls_x509_privkey_t key, - const MHD_gnutls_datum_t * data, - MHD_gnutls_x509_crt_fmt_t format, - const char *pass, unsigned int flags); + const MHD_gnutls_datum_t * data, + MHD_gnutls_x509_crt_fmt_t format, + const char *pass, + unsigned int flags); int MHD_gnutls_x509_privkey_import_rsa_raw (MHD_gnutls_x509_privkey_t key, - const MHD_gnutls_datum_t * m, - const MHD_gnutls_datum_t * e, - const MHD_gnutls_datum_t * d, - const MHD_gnutls_datum_t * p, - const MHD_gnutls_datum_t * q, - const MHD_gnutls_datum_t * u); + const MHD_gnutls_datum_t * m, + const MHD_gnutls_datum_t * e, + const MHD_gnutls_datum_t * d, + const MHD_gnutls_datum_t * p, + const MHD_gnutls_datum_t * q, + const MHD_gnutls_datum_t * u); int MHD_gnutls_x509_privkey_export_dsa_raw (MHD_gnutls_x509_privkey_t key, - MHD_gnutls_datum_t * p, - MHD_gnutls_datum_t * q, - MHD_gnutls_datum_t * g, - MHD_gnutls_datum_t * y, - MHD_gnutls_datum_t * x); + MHD_gnutls_datum_t * p, + MHD_gnutls_datum_t * q, + MHD_gnutls_datum_t * g, + MHD_gnutls_datum_t * y, + MHD_gnutls_datum_t * x); int MHD_gnutls_x509_privkey_import_dsa_raw (MHD_gnutls_x509_privkey_t key, - const MHD_gnutls_datum_t * p, - const MHD_gnutls_datum_t * q, - const MHD_gnutls_datum_t * g, - const MHD_gnutls_datum_t * y, - const MHD_gnutls_datum_t * x); - - int MHD_gnutls_x509_privkey_get_pk_algorithm (MHD_gnutls_x509_privkey_t key); + const MHD_gnutls_datum_t * p, + const MHD_gnutls_datum_t * q, + const MHD_gnutls_datum_t * g, + const MHD_gnutls_datum_t * y, + const MHD_gnutls_datum_t * x); + + int MHD_gnutls_x509_privkey_get_pk_algorithm (MHD_gnutls_x509_privkey_t + key); int MHD_gnutls_x509_privkey_get_key_id (MHD_gnutls_x509_privkey_t key, - unsigned int flags, - unsigned char *output_data, - size_t * output_data_size); + unsigned int flags, + unsigned char *output_data, + size_t * output_data_size); int MHD_gnutls_x509_privkey_export (MHD_gnutls_x509_privkey_t key, - MHD_gnutls_x509_crt_fmt_t format, - void *output_data, - size_t * output_data_size); + MHD_gnutls_x509_crt_fmt_t format, + void *output_data, + size_t * output_data_size); int MHD_gnutls_x509_privkey_export_pkcs8 (MHD_gnutls_x509_privkey_t key, - MHD_gnutls_x509_crt_fmt_t format, - const char *password, - unsigned int flags, - void *output_data, - size_t * output_data_size); + MHD_gnutls_x509_crt_fmt_t format, + const char *password, + unsigned int flags, + void *output_data, + size_t * output_data_size); int MHD_gnutls_x509_privkey_export_rsa_raw (MHD_gnutls_x509_privkey_t key, - MHD_gnutls_datum_t * m, - MHD_gnutls_datum_t * e, - MHD_gnutls_datum_t * d, - MHD_gnutls_datum_t * p, - MHD_gnutls_datum_t * q, - MHD_gnutls_datum_t * u); + MHD_gnutls_datum_t * m, + MHD_gnutls_datum_t * e, + MHD_gnutls_datum_t * d, + MHD_gnutls_datum_t * p, + MHD_gnutls_datum_t * q, + MHD_gnutls_datum_t * u); int MHD_gnutls_x509_privkey_verify_data (MHD_gnutls_x509_privkey_t key, - unsigned int flags, - const MHD_gnutls_datum_t * data, - const MHD_gnutls_datum_t * signature); + unsigned int flags, + const MHD_gnutls_datum_t * data, + const MHD_gnutls_datum_t * + signature); /* Certificate request stuff. */ @@ -485,53 +501,57 @@ extern "C" int MHD_gnutls_x509_crq_init (MHD_gnutls_x509_crq_t * crq); void MHD_gnutls_x509_crq_deinit (MHD_gnutls_x509_crq_t crq); int MHD_gnutls_x509_crq_import (MHD_gnutls_x509_crq_t crq, - const MHD_gnutls_datum_t * data, - MHD_gnutls_x509_crt_fmt_t format); + const MHD_gnutls_datum_t * data, + MHD_gnutls_x509_crt_fmt_t format); int MHD_gnutls_x509_crq_get_pk_algorithm (MHD_gnutls_x509_crq_t crq, - unsigned int *bits); + unsigned int *bits); int MHD_gnutls_x509_crq_get_dn (MHD_gnutls_x509_crq_t crq, - char *buf, size_t * sizeof_buf); + char *buf, size_t * sizeof_buf); int MHD_gnutls_x509_crq_get_dn_oid (MHD_gnutls_x509_crq_t crq, - int indx, void *oid, size_t * sizeof_oid); + int indx, void *oid, + size_t * sizeof_oid); int MHD_gnutls_x509_crq_get_dn_by_oid (MHD_gnutls_x509_crq_t crq, - const char *oid, - int indx, - unsigned int raw_flag, - void *buf, size_t * sizeof_buf); + const char *oid, int indx, + unsigned int raw_flag, void *buf, + size_t * sizeof_buf); int MHD_gnutls_x509_crq_set_dn_by_oid (MHD_gnutls_x509_crq_t crq, - const char *oid, - unsigned int raw_flag, - const void *name, - unsigned int sizeof_name); + const char *oid, + unsigned int raw_flag, + const void *name, + unsigned int sizeof_name); int MHD_gnutls_x509_crq_set_version (MHD_gnutls_x509_crq_t crq, - unsigned int version); + unsigned int version); int MHD_gnutls_x509_crq_set_key (MHD_gnutls_x509_crq_t crq, - MHD_gnutls_x509_privkey_t key); + MHD_gnutls_x509_privkey_t key); int MHD_gnutls_x509_crq_sign2 (MHD_gnutls_x509_crq_t crq, - MHD_gnutls_x509_privkey_t key, - enum MHD_GNUTLS_HashAlgorithm, - unsigned int flags); - int MHD_gnutls_x509_crq_sign (MHD_gnutls_x509_crq_t crq, MHD_gnutls_x509_privkey_t key); + MHD_gnutls_x509_privkey_t key, + enum MHD_GNUTLS_HashAlgorithm, + unsigned int flags); + int MHD_gnutls_x509_crq_sign (MHD_gnutls_x509_crq_t crq, + MHD_gnutls_x509_privkey_t key); int MHD_gnutls_x509_crq_set_challenge_password (MHD_gnutls_x509_crq_t crq, - const char *pass); + const char *pass); int MHD_gnutls_x509_crq_get_challenge_password (MHD_gnutls_x509_crq_t crq, - char *pass, - size_t * sizeof_pass); + char *pass, + size_t * sizeof_pass); int MHD_gnutls_x509_crq_set_attribute_by_oid (MHD_gnutls_x509_crq_t crq, - const char *oid, - void *buf, size_t sizeof_buf); + const char *oid, + void *buf, size_t sizeof_buf); int MHD_gnutls_x509_crq_get_attribute_by_oid (MHD_gnutls_x509_crq_t crq, - const char *oid, - int indx, - void *buf, size_t * sizeof_buf); + const char *oid, + int indx, + void *buf, + size_t * sizeof_buf); int MHD_gnutls_x509_crq_export (MHD_gnutls_x509_crq_t crq, - MHD_gnutls_x509_crt_fmt_t format, - void *output_data, size_t * output_data_size); + MHD_gnutls_x509_crt_fmt_t format, + void *output_data, + size_t * output_data_size); - int MHD_gnutls_x509_crt_set_crq (MHD_gnutls_x509_crt_t crt, MHD_gnutls_x509_crq_t crq); + int MHD_gnutls_x509_crt_set_crq (MHD_gnutls_x509_crt_t crt, + MHD_gnutls_x509_crq_t crq); #ifdef __cplusplus } @@ -605,65 +625,66 @@ typedef struct MHD_gtls_x509_privkey_int } MHD_gnutls_x509_privkey_int; int MHD_gnutls_x509_crt_get_issuer_dn_by_oid (MHD_gnutls_x509_crt_t cert, - const char *oid, - int indx, - unsigned int raw_flag, - void *buf, size_t * sizeof_buf); + const char *oid, + int indx, + unsigned int raw_flag, + void *buf, size_t * sizeof_buf); int MHD_gnutls_x509_crt_get_subject_alt_name (MHD_gnutls_x509_crt_t cert, - unsigned int seq, - void *ret, - size_t * ret_size, - unsigned int *critical); + unsigned int seq, + void *ret, + size_t * ret_size, + unsigned int *critical); int MHD_gnutls_x509_crt_get_dn_by_oid (MHD_gnutls_x509_crt_t cert, - const char *oid, - int indx, - unsigned int raw_flag, - void *buf, size_t * sizeof_buf); + const char *oid, + int indx, + unsigned int raw_flag, + void *buf, size_t * sizeof_buf); int MHD_gnutls_x509_crt_get_ca_status (MHD_gnutls_x509_crt_t cert, - unsigned int *critical); + unsigned int *critical); int MHD_gnutls_x509_crt_get_pk_algorithm (MHD_gnutls_x509_crt_t cert, - unsigned int *bits); + unsigned int *bits); int MHD_gnutls_x509_crt_get_serial (MHD_gnutls_x509_crt_t cert, - void *result, size_t * result_size); + void *result, size_t * result_size); int MHD__gnutls_x509_compare_raw_dn (const MHD_gnutls_datum_t * dn1, - const MHD_gnutls_datum_t * dn2); + const MHD_gnutls_datum_t * dn2); int MHD_gnutls_x509_crt_check_revocation (MHD_gnutls_x509_crt_t cert, - const MHD_gnutls_x509_crl_t * crl_list, - int crl_list_length); + const MHD_gnutls_x509_crl_t * + crl_list, int crl_list_length); -int MHD__gnutls_x509_crl_cpy (MHD_gnutls_x509_crl_t dest, MHD_gnutls_x509_crl_t src); +int MHD__gnutls_x509_crl_cpy (MHD_gnutls_x509_crl_t dest, + MHD_gnutls_x509_crl_t src); int MHD__gnutls_x509_crl_get_raw_issuer_dn (MHD_gnutls_x509_crl_t crl, - MHD_gnutls_datum_t * dn); + MHD_gnutls_datum_t * dn); int MHD_gnutls_x509_crl_get_crt_count (MHD_gnutls_x509_crl_t crl); int MHD_gnutls_x509_crl_get_crt_serial (MHD_gnutls_x509_crl_t crl, - int indx, - unsigned char *serial, - size_t * serial_size, time_t * t); + int indx, + unsigned char *serial, + size_t * serial_size, time_t * t); void MHD_gnutls_x509_crl_deinit (MHD_gnutls_x509_crl_t crl); int MHD_gnutls_x509_crl_init (MHD_gnutls_x509_crl_t * crl); int MHD_gnutls_x509_crl_import (MHD_gnutls_x509_crl_t crl, - const MHD_gnutls_datum_t * data, - MHD_gnutls_x509_crt_fmt_t format); + const MHD_gnutls_datum_t * data, + MHD_gnutls_x509_crt_fmt_t format); int MHD_gnutls_x509_crl_export (MHD_gnutls_x509_crl_t crl, - MHD_gnutls_x509_crt_fmt_t format, - void *output_data, size_t * output_data_size); + MHD_gnutls_x509_crt_fmt_t format, + void *output_data, size_t * output_data_size); int MHD_gnutls_x509_crt_init (MHD_gnutls_x509_crt_t * cert); void MHD_gnutls_x509_crt_deinit (MHD_gnutls_x509_crt_t cert); int MHD_gnutls_x509_crt_import (MHD_gnutls_x509_crt_t cert, - const MHD_gnutls_datum_t * data, - MHD_gnutls_x509_crt_fmt_t format); + const MHD_gnutls_datum_t * data, + MHD_gnutls_x509_crt_fmt_t format); int MHD_gnutls_x509_crt_export (MHD_gnutls_x509_crt_t cert, - MHD_gnutls_x509_crt_fmt_t format, - void *output_data, size_t * output_data_size); + MHD_gnutls_x509_crt_fmt_t format, + void *output_data, size_t * output_data_size); int MHD_gnutls_x509_crt_get_key_usage (MHD_gnutls_x509_crt_t cert, - unsigned int *key_usage, - unsigned int *critical); + unsigned int *key_usage, + unsigned int *critical); int MHD_gnutls_x509_crt_get_signature_algorithm (MHD_gnutls_x509_crt_t cert); int MHD_gnutls_x509_crt_get_version (MHD_gnutls_x509_crt_t cert); @@ -671,30 +692,31 @@ int MHD_gnutls_x509_privkey_init (MHD_gnutls_x509_privkey_t * key); void MHD_gnutls_x509_privkey_deinit (MHD_gnutls_x509_privkey_t key); int MHD_gnutls_x509_privkey_generate (MHD_gnutls_x509_privkey_t key, - enum MHD_GNUTLS_PublicKeyAlgorithm algo, - unsigned int bits, unsigned int flags); + enum MHD_GNUTLS_PublicKeyAlgorithm algo, + unsigned int bits, unsigned int flags); int MHD_gnutls_x509_privkey_import (MHD_gnutls_x509_privkey_t key, - const MHD_gnutls_datum_t * data, - MHD_gnutls_x509_crt_fmt_t format); + const MHD_gnutls_datum_t * data, + MHD_gnutls_x509_crt_fmt_t format); int MHD_gnutls_x509_privkey_get_pk_algorithm (MHD_gnutls_x509_privkey_t key); int MHD_gnutls_x509_privkey_import_rsa_raw (MHD_gnutls_x509_privkey_t key, - const MHD_gnutls_datum_t * m, - const MHD_gnutls_datum_t * e, - const MHD_gnutls_datum_t * d, - const MHD_gnutls_datum_t * p, - const MHD_gnutls_datum_t * q, - const MHD_gnutls_datum_t * u); + const MHD_gnutls_datum_t * m, + const MHD_gnutls_datum_t * e, + const MHD_gnutls_datum_t * d, + const MHD_gnutls_datum_t * p, + const MHD_gnutls_datum_t * q, + const MHD_gnutls_datum_t * u); int MHD_gnutls_x509_privkey_export_rsa_raw (MHD_gnutls_x509_privkey_t key, - MHD_gnutls_datum_t * m, - MHD_gnutls_datum_t * e, - MHD_gnutls_datum_t * d, - MHD_gnutls_datum_t * p, - MHD_gnutls_datum_t * q, - MHD_gnutls_datum_t * u); + MHD_gnutls_datum_t * m, + MHD_gnutls_datum_t * e, + MHD_gnutls_datum_t * d, + MHD_gnutls_datum_t * p, + MHD_gnutls_datum_t * q, + MHD_gnutls_datum_t * u); int MHD_gnutls_x509_privkey_export (MHD_gnutls_x509_privkey_t key, - MHD_gnutls_x509_crt_fmt_t format, - void *output_data, size_t * output_data_size); + MHD_gnutls_x509_crt_fmt_t format, + void *output_data, + size_t * output_data_size); #define GNUTLS_CRL_REASON_UNUSED 128 #define GNUTLS_CRL_REASON_KEY_COMPROMISE 64 diff --git a/src/daemon/https/x509/x509_privkey.c b/src/daemon/https/x509/x509_privkey.c @@ -104,7 +104,8 @@ MHD_gnutls_x509_privkey_deinit (MHD_gnutls_x509_privkey_t key) * **/ int -MHD_gnutls_x509_privkey_cpy (MHD_gnutls_x509_privkey_t dst, MHD_gnutls_x509_privkey_t src) +MHD_gnutls_x509_privkey_cpy (MHD_gnutls_x509_privkey_t dst, + MHD_gnutls_x509_privkey_t src) { int i, ret; @@ -148,14 +149,14 @@ MHD_gnutls_x509_privkey_cpy (MHD_gnutls_x509_privkey_t dst, MHD_gnutls_x509_priv */ ASN1_TYPE MHD__gnutls_privkey_decode_pkcs1_rsa_key (const MHD_gnutls_datum_t * raw_key, - MHD_gnutls_x509_privkey_t pkey) + MHD_gnutls_x509_privkey_t pkey) { int result; ASN1_TYPE pkey_asn; if ((result = MHD__asn1_create_element (MHD__gnutls_getMHD__gnutls_asn (), - "GNUTLS.RSAPrivateKey", - &pkey_asn)) != ASN1_SUCCESS) + "GNUTLS.RSAPrivateKey", + &pkey_asn)) != ASN1_SUCCESS) { MHD_gnutls_assert (); return NULL; @@ -168,43 +169,44 @@ MHD__gnutls_privkey_decode_pkcs1_rsa_key (const MHD_gnutls_datum_t * raw_key, return NULL; } - result = MHD__asn1_der_decoding (&pkey_asn, raw_key->data, raw_key->size, NULL); + result = + MHD__asn1_der_decoding (&pkey_asn, raw_key->data, raw_key->size, NULL); if (result != ASN1_SUCCESS) { MHD_gnutls_assert (); goto error; } - if ((result = MHD__gnutls_x509_read_int (pkey_asn, "modulus", &pkey->params[0])) - < 0) + if ((result = + MHD__gnutls_x509_read_int (pkey_asn, "modulus", &pkey->params[0])) < 0) { MHD_gnutls_assert (); goto error; } if ((result = MHD__gnutls_x509_read_int (pkey_asn, "publicExponent", - &pkey->params[1])) < 0) + &pkey->params[1])) < 0) { MHD_gnutls_assert (); goto error; } if ((result = MHD__gnutls_x509_read_int (pkey_asn, "privateExponent", - &pkey->params[2])) < 0) + &pkey->params[2])) < 0) { MHD_gnutls_assert (); goto error; } - if ((result = MHD__gnutls_x509_read_int (pkey_asn, "prime1", &pkey->params[3])) - < 0) + if ((result = + MHD__gnutls_x509_read_int (pkey_asn, "prime1", &pkey->params[3])) < 0) { MHD_gnutls_assert (); goto error; } - if ((result = MHD__gnutls_x509_read_int (pkey_asn, "prime2", &pkey->params[4])) - < 0) + if ((result = + MHD__gnutls_x509_read_int (pkey_asn, "prime2", &pkey->params[4])) < 0) { MHD_gnutls_assert (); goto error; @@ -227,7 +229,7 @@ MHD__gnutls_privkey_decode_pkcs1_rsa_key (const MHD_gnutls_datum_t * raw_key, /* p, q */ #else if ((result = MHD__gnutls_x509_read_int (pkey_asn, "coefficient", - &pkey->params[5])) < 0) + &pkey->params[5])) < 0) { MHD_gnutls_assert (); goto error; @@ -267,8 +269,8 @@ error:MHD__asn1_delete_structure (&pkey_asn); **/ int MHD_gnutls_x509_privkey_import (MHD_gnutls_x509_privkey_t key, - const MHD_gnutls_datum_t * data, - MHD_gnutls_x509_crt_fmt_t format) + const MHD_gnutls_datum_t * data, + MHD_gnutls_x509_crt_fmt_t format) { int result = 0, need_free = 0; MHD_gnutls_datum_t _data; @@ -291,7 +293,9 @@ MHD_gnutls_x509_privkey_import (MHD_gnutls_x509_privkey_t key, /* Try the first header */ result - = MHD__gnutls_fbase64_decode (PEM_KEY_RSA, data->data, data->size, &out); + = + MHD__gnutls_fbase64_decode (PEM_KEY_RSA, data->data, data->size, + &out); key->pk_algorithm = MHD_GNUTLS_PK_RSA; _data.data = out; @@ -360,12 +364,12 @@ MHD_gnutls_x509_privkey_import (MHD_gnutls_x509_privkey_t key, **/ int MHD_gnutls_x509_privkey_import_rsa_raw (MHD_gnutls_x509_privkey_t key, - const MHD_gnutls_datum_t * m, - const MHD_gnutls_datum_t * e, - const MHD_gnutls_datum_t * d, - const MHD_gnutls_datum_t * p, - const MHD_gnutls_datum_t * q, - const MHD_gnutls_datum_t * u) + const MHD_gnutls_datum_t * m, + const MHD_gnutls_datum_t * e, + const MHD_gnutls_datum_t * d, + const MHD_gnutls_datum_t * p, + const MHD_gnutls_datum_t * q, + const MHD_gnutls_datum_t * u) { int i = 0, ret; size_t siz = 0; @@ -417,7 +421,8 @@ MHD_gnutls_x509_privkey_import_rsa_raw (MHD_gnutls_x509_privkey_t key, } #ifdef CALC_COEFF - key->params[5] = MHD__gnutls_mpi_snew (MHD__gnutls_mpi_get_nbits (key->params[0])); + key->params[5] = + MHD__gnutls_mpi_snew (MHD__gnutls_mpi_get_nbits (key->params[0])); if (key->params[5] == NULL) { @@ -501,7 +506,7 @@ MHD__gnutls_asn1_encode_rsa (ASN1_TYPE * c2, mpi_t * params) /* Now generate exp1 and exp2 */ - exp1 = MHD__gnutls_mpi_salloc_like (params[0]); /* like modulus */ + exp1 = MHD__gnutls_mpi_salloc_like (params[0]); /* like modulus */ if (exp1 == NULL) { MHD_gnutls_assert (); @@ -600,8 +605,8 @@ MHD__gnutls_asn1_encode_rsa (ASN1_TYPE * c2, mpi_t * params) */ if ((result = - MHD__asn1_create_element (MHD__gnutls_getMHD__gnutls_asn (), "GNUTLS.RSAPrivateKey", - c2)) != ASN1_SUCCESS) + MHD__asn1_create_element (MHD__gnutls_getMHD__gnutls_asn (), + "GNUTLS.RSAPrivateKey", c2)) != ASN1_SUCCESS) { MHD_gnutls_assert (); result = MHD_gtls_asn2err (result); @@ -618,16 +623,18 @@ MHD__gnutls_asn1_encode_rsa (ASN1_TYPE * c2, mpi_t * params) goto cleanup; } - if ((result = MHD__asn1_write_value (*c2, "publicExponent", pube_data, size[1])) - != ASN1_SUCCESS) + if ((result = + MHD__asn1_write_value (*c2, "publicExponent", pube_data, + size[1])) != ASN1_SUCCESS) { MHD_gnutls_assert (); result = MHD_gtls_asn2err (result); goto cleanup; } - if ((result = MHD__asn1_write_value (*c2, "privateExponent", prie_data, size[2])) - != ASN1_SUCCESS) + if ((result = + MHD__asn1_write_value (*c2, "privateExponent", prie_data, + size[2])) != ASN1_SUCCESS) { MHD_gnutls_assert (); result = MHD_gtls_asn2err (result); @@ -682,14 +689,15 @@ MHD__gnutls_asn1_encode_rsa (ASN1_TYPE * c2, mpi_t * params) MHD_gnutls_free (all_data); if ((result = MHD__asn1_write_value (*c2, "otherPrimeInfos", - NULL, 0)) != ASN1_SUCCESS) + NULL, 0)) != ASN1_SUCCESS) { MHD_gnutls_assert (); result = MHD_gtls_asn2err (result); goto cleanup; } - if ((result = MHD__asn1_write_value (*c2, "version", &null, 1)) != ASN1_SUCCESS) + if ((result = + MHD__asn1_write_value (*c2, "version", &null, 1)) != ASN1_SUCCESS) { MHD_gnutls_assert (); result = MHD_gtls_asn2err (result); @@ -760,8 +768,8 @@ MHD__gnutls_asn1_encode_dsa (ASN1_TYPE * c2, mpi_t * params) */ if ((result = - MHD__asn1_create_element (MHD__gnutls_getMHD__gnutls_asn (), "GNUTLS.DSAPrivateKey", - c2)) != ASN1_SUCCESS) + MHD__asn1_create_element (MHD__gnutls_getMHD__gnutls_asn (), + "GNUTLS.DSAPrivateKey", c2)) != ASN1_SUCCESS) { MHD_gnutls_assert (); result = MHD_gtls_asn2err (result); @@ -770,28 +778,32 @@ MHD__gnutls_asn1_encode_dsa (ASN1_TYPE * c2, mpi_t * params) /* Write PRIME */ - if ((result = MHD__asn1_write_value (*c2, "p", p_data, size[0])) != ASN1_SUCCESS) + if ((result = + MHD__asn1_write_value (*c2, "p", p_data, size[0])) != ASN1_SUCCESS) { MHD_gnutls_assert (); result = MHD_gtls_asn2err (result); goto cleanup; } - if ((result = MHD__asn1_write_value (*c2, "q", q_data, size[1])) != ASN1_SUCCESS) + if ((result = + MHD__asn1_write_value (*c2, "q", q_data, size[1])) != ASN1_SUCCESS) { MHD_gnutls_assert (); result = MHD_gtls_asn2err (result); goto cleanup; } - if ((result = MHD__asn1_write_value (*c2, "g", g_data, size[2])) != ASN1_SUCCESS) + if ((result = + MHD__asn1_write_value (*c2, "g", g_data, size[2])) != ASN1_SUCCESS) { MHD_gnutls_assert (); result = MHD_gtls_asn2err (result); goto cleanup; } - if ((result = MHD__asn1_write_value (*c2, "Y", y_data, size[3])) != ASN1_SUCCESS) + if ((result = + MHD__asn1_write_value (*c2, "Y", y_data, size[3])) != ASN1_SUCCESS) { MHD_gnutls_assert (); result = MHD_gtls_asn2err (result); @@ -808,7 +820,8 @@ MHD__gnutls_asn1_encode_dsa (ASN1_TYPE * c2, mpi_t * params) MHD_gnutls_free (all_data); - if ((result = MHD__asn1_write_value (*c2, "version", &null, 1)) != ASN1_SUCCESS) + if ((result = + MHD__asn1_write_value (*c2, "version", &null, 1)) != ASN1_SUCCESS) { MHD_gnutls_assert (); result = MHD_gtls_asn2err (result); @@ -822,4 +835,3 @@ cleanup:MHD__asn1_delete_structure (c2); return result; } - diff --git a/src/daemon/https/x509/x509_verify.c b/src/daemon/https/x509/x509_verify.c @@ -42,20 +42,21 @@ #include <verify.h> static int MHD__gnutls_verify_certificate2 (MHD_gnutls_x509_crt_t cert, - const MHD_gnutls_x509_crt_t * trusted_cas, - int tcas_size, - unsigned int flags, - unsigned int *output); + const MHD_gnutls_x509_crt_t * + trusted_cas, int tcas_size, + unsigned int flags, + unsigned int *output); int MHD__gnutls_x509_verify_signature (const MHD_gnutls_datum_t * signed_data, - const MHD_gnutls_datum_t * signature, - MHD_gnutls_x509_crt_t issuer); + const MHD_gnutls_datum_t * signature, + MHD_gnutls_x509_crt_t issuer); static - int is_crl_issuer (MHD_gnutls_x509_crl_t crl, MHD_gnutls_x509_crt_t issuer_cert); + int is_crl_issuer (MHD_gnutls_x509_crl_t crl, + MHD_gnutls_x509_crt_t issuer_cert); static int MHD__gnutls_verify_crl2 (MHD_gnutls_x509_crl_t crl, - const MHD_gnutls_x509_crt_t * trusted_cas, - int tcas_size, - unsigned int flags, unsigned int *output); + const MHD_gnutls_x509_crt_t * trusted_cas, + int tcas_size, unsigned int flags, + unsigned int *output); /* Checks if the issuer of a certificate is a * Certificate Authority, or if the certificate is the same @@ -88,7 +89,7 @@ check_if_ca (MHD_gnutls_x509_crt_t cert, */ result = MHD__gnutls_x509_get_signed_data (issuer->cert, "tbsCertificate", - &issuer_signed_data); + &issuer_signed_data); if (result < 0) { MHD_gnutls_assert (); @@ -96,7 +97,7 @@ check_if_ca (MHD_gnutls_x509_crt_t cert, } result = MHD__gnutls_x509_get_signed_data (cert->cert, "tbsCertificate", - &cert_signed_data); + &cert_signed_data); if (result < 0) { MHD_gnutls_assert (); @@ -104,7 +105,7 @@ check_if_ca (MHD_gnutls_x509_crt_t cert, } result = MHD__gnutls_x509_get_signature (issuer->cert, "signature", - &issuer_signature); + &issuer_signature); if (result < 0) { MHD_gnutls_assert (); @@ -228,9 +229,9 @@ find_issuer (MHD_gnutls_x509_crt_t cert, */ static int MHD__gnutls_verify_certificate2 (MHD_gnutls_x509_crt_t cert, - const MHD_gnutls_x509_crt_t * trusted_cas, - int tcas_size, - unsigned int flags, unsigned int *output) + const MHD_gnutls_x509_crt_t * trusted_cas, + int tcas_size, + unsigned int flags, unsigned int *output) { MHD_gnutls_datum_t cert_signed_data = { NULL, 0 @@ -287,7 +288,7 @@ MHD__gnutls_verify_certificate2 (MHD_gnutls_x509_crt_t cert, } result = MHD__gnutls_x509_get_signed_data (cert->cert, "tbsCertificate", - &cert_signed_data); + &cert_signed_data); if (result < 0) { MHD_gnutls_assert (); @@ -303,7 +304,7 @@ MHD__gnutls_verify_certificate2 (MHD_gnutls_x509_crt_t cert, } ret = MHD__gnutls_x509_verify_signature (&cert_signed_data, &cert_signature, - issuer); + issuer); if (ret < 0) { MHD_gnutls_assert (); @@ -360,7 +361,7 @@ cleanup:MHD__gnutls_free_datum (&cert_signed_data); **/ int MHD_gnutls_x509_crt_check_issuer (MHD_gnutls_x509_crt_t cert, - MHD_gnutls_x509_crt_t issuer) + MHD_gnutls_x509_crt_t issuer) { return is_issuer (cert, issuer); } @@ -377,12 +378,12 @@ MHD_gnutls_x509_crt_check_issuer (MHD_gnutls_x509_crt_t cert, * lead to a trusted CA in order to be trusted. */ static unsigned int -MHD__gnutls_x509_verify_certificate (const MHD_gnutls_x509_crt_t * certificate_list, - int clist_size, - const MHD_gnutls_x509_crt_t * trusted_cas, - int tcas_size, - const MHD_gnutls_x509_crl_t * CRLs, - int crls_size, unsigned int flags) +MHD__gnutls_x509_verify_certificate (const MHD_gnutls_x509_crt_t * + certificate_list, int clist_size, + const MHD_gnutls_x509_crt_t * + trusted_cas, int tcas_size, + const MHD_gnutls_x509_crl_t * CRLs, + int crls_size, unsigned int flags) { int i = 0, ret; unsigned int status = 0, output; @@ -394,7 +395,8 @@ MHD__gnutls_x509_verify_certificate (const MHD_gnutls_x509_crt_t * certificate_l * in self signed etc certificates. */ ret = MHD__gnutls_verify_certificate2 (certificate_list[clist_size - 1], - trusted_cas, tcas_size, flags, &output); + trusted_cas, tcas_size, flags, + &output); if (ret == 0) { @@ -414,7 +416,7 @@ MHD__gnutls_x509_verify_certificate (const MHD_gnutls_x509_crt_t * certificate_l for (i = 0; i < clist_size; i++) { ret = MHD_gnutls_x509_crt_check_revocation (certificate_list[i], - CRLs, crls_size); + CRLs, crls_size); if (ret == 1) { /* revoked */ status |= GNUTLS_CERT_REVOKED; @@ -429,7 +431,7 @@ MHD__gnutls_x509_verify_certificate (const MHD_gnutls_x509_crt_t * certificate_l * leads to a trusted party by us, not the server's). */ if (MHD_gnutls_x509_crt_check_issuer (certificate_list[clist_size - 1], - certificate_list[clist_size - 1]) > 0 + certificate_list[clist_size - 1]) > 0 && clist_size > 0) { clist_size--; @@ -448,8 +450,8 @@ MHD__gnutls_x509_verify_certificate (const MHD_gnutls_x509_crt_t * certificate_l if (!(flags & GNUTLS_VERIFY_ALLOW_ANY_X509_V1_CA_CRT)) flags ^= GNUTLS_VERIFY_ALLOW_X509_V1_CA_CRT; if ((ret = MHD__gnutls_verify_certificate2 (certificate_list[i - 1], - &certificate_list[i], 1, flags, - NULL)) == 0) + &certificate_list[i], 1, + flags, NULL)) == 0) { status |= GNUTLS_CERT_INVALID; return status; @@ -474,8 +476,8 @@ decode_ber_digest_info (const MHD_gnutls_datum_t * info, int len; if ((result = MHD__asn1_create_element (MHD__gnutls_getMHD__gnutls_asn (), - "GNUTLS.DigestInfo", - &dinfo)) != ASN1_SUCCESS) + "GNUTLS.DigestInfo", + &dinfo)) != ASN1_SUCCESS) { MHD_gnutls_assert (); return MHD_gtls_asn2err (result); @@ -490,7 +492,8 @@ decode_ber_digest_info (const MHD_gnutls_datum_t * info, } len = sizeof (str) - 1; - result = MHD__asn1_read_value (dinfo, "digestAlgorithm.algorithm", str, &len); + result = + MHD__asn1_read_value (dinfo, "digestAlgorithm.algorithm", str, &len); if (result != ASN1_SUCCESS) { MHD_gnutls_assert (); @@ -511,7 +514,8 @@ decode_ber_digest_info (const MHD_gnutls_datum_t * info, } len = sizeof (str) - 1; - result = MHD__asn1_read_value (dinfo, "digestAlgorithm.parameters", str, &len); + result = + MHD__asn1_read_value (dinfo, "digestAlgorithm.parameters", str, &len); /* To avoid permitting garbage in the parameters field, either the parameters field is not present, or it contains 0x05 0x00. */ if (! @@ -640,8 +644,8 @@ verify_sig (const MHD_gnutls_datum_t * tbs, */ int MHD__gnutls_x509_verify_signature (const MHD_gnutls_datum_t * tbs, - const MHD_gnutls_datum_t * signature, - MHD_gnutls_x509_crt_t issuer) + const MHD_gnutls_datum_t * signature, + MHD_gnutls_x509_crt_t issuer) { mpi_t issuer_params[MAX_PUBLIC_PARAMS_SIZE]; int ret, issuer_params_size, i; @@ -650,16 +654,18 @@ MHD__gnutls_x509_verify_signature (const MHD_gnutls_datum_t * tbs, */ issuer_params_size = MAX_PUBLIC_PARAMS_SIZE; ret = - MHD__gnutls_x509_crt_get_mpis (issuer, issuer_params, &issuer_params_size); + MHD__gnutls_x509_crt_get_mpis (issuer, issuer_params, + &issuer_params_size); if (ret < 0) { MHD_gnutls_assert (); return ret; } - ret = verify_sig (tbs, signature, MHD_gnutls_x509_crt_get_pk_algorithm (issuer, - NULL), - issuer_params, issuer_params_size); + ret = + verify_sig (tbs, signature, + MHD_gnutls_x509_crt_get_pk_algorithm (issuer, NULL), + issuer_params, issuer_params_size); if (ret < 0) { MHD_gnutls_assert (); @@ -683,8 +689,9 @@ MHD__gnutls_x509_verify_signature (const MHD_gnutls_datum_t * tbs, */ int MHD__gnutls_x509_privkey_verify_signature (const MHD_gnutls_datum_t * tbs, - const MHD_gnutls_datum_t * signature, - MHD_gnutls_x509_privkey_t issuer) + const MHD_gnutls_datum_t * + signature, + MHD_gnutls_x509_privkey_t issuer) { int ret; @@ -734,12 +741,12 @@ MHD__gnutls_x509_privkey_verify_signature (const MHD_gnutls_datum_t * tbs, **/ int MHD_gnutls_x509_crt_list_verify (const MHD_gnutls_x509_crt_t * cert_list, - int cert_list_length, - const MHD_gnutls_x509_crt_t * CA_list, - int CA_list_length, - const MHD_gnutls_x509_crl_t * CRL_list, - int CRL_list_length, - unsigned int flags, unsigned int *verify) + int cert_list_length, + const MHD_gnutls_x509_crt_t * CA_list, + int CA_list_length, + const MHD_gnutls_x509_crl_t * CRL_list, + int CRL_list_length, + unsigned int flags, unsigned int *verify) { if (cert_list == NULL || cert_list_length == 0) return GNUTLS_E_NO_CERTIFICATE_FOUND; @@ -747,9 +754,9 @@ MHD_gnutls_x509_crt_list_verify (const MHD_gnutls_x509_crt_t * cert_list, /* Verify certificate */ *verify = MHD__gnutls_x509_verify_certificate (cert_list, cert_list_length, - CA_list, CA_list_length, - CRL_list, CRL_list_length, - flags); + CA_list, CA_list_length, + CRL_list, CRL_list_length, + flags); return 0; } @@ -770,15 +777,15 @@ MHD_gnutls_x509_crt_list_verify (const MHD_gnutls_x509_crt_t * cert_list, **/ int MHD_gnutls_x509_crt_verify (MHD_gnutls_x509_crt_t cert, - const MHD_gnutls_x509_crt_t * CA_list, - int CA_list_length, - unsigned int flags, unsigned int *verify) + const MHD_gnutls_x509_crt_t * CA_list, + int CA_list_length, + unsigned int flags, unsigned int *verify) { int ret; /* Verify certificate */ ret = MHD__gnutls_verify_certificate2 (cert, CA_list, CA_list_length, flags, - verify); + verify); if (ret < 0) { MHD_gnutls_assert (); @@ -804,7 +811,7 @@ MHD_gnutls_x509_crt_verify (MHD_gnutls_x509_crt_t cert, **/ int MHD_gnutls_x509_crl_check_issuer (MHD_gnutls_x509_crl_t cert, - MHD_gnutls_x509_crt_t issuer) + MHD_gnutls_x509_crt_t issuer) { return is_crl_issuer (cert, issuer); } @@ -826,9 +833,9 @@ MHD_gnutls_x509_crl_check_issuer (MHD_gnutls_x509_crl_t cert, **/ int MHD_gnutls_x509_crl_verify (MHD_gnutls_x509_crl_t crl, - const MHD_gnutls_x509_crt_t * CA_list, - int CA_list_length, unsigned int flags, - unsigned int *verify) + const MHD_gnutls_x509_crt_t * CA_list, + int CA_list_length, unsigned int flags, + unsigned int *verify) { int ret; /* Verify crl @@ -906,8 +913,9 @@ find_crl_issuer (MHD_gnutls_x509_crl_t crl, */ static int MHD__gnutls_verify_crl2 (MHD_gnutls_x509_crl_t crl, - const MHD_gnutls_x509_crt_t * trusted_cas, - int tcas_size, unsigned int flags, unsigned int *output) + const MHD_gnutls_x509_crt_t * trusted_cas, + int tcas_size, unsigned int flags, + unsigned int *output) { /* CRL is ignored for now */ MHD_gnutls_datum_t crl_signed_data = { NULL, 0 }; @@ -951,14 +959,16 @@ MHD__gnutls_verify_crl2 (MHD_gnutls_x509_crl_t crl, } result = - MHD__gnutls_x509_get_signed_data (crl->crl, "tbsCertList", &crl_signed_data); + MHD__gnutls_x509_get_signed_data (crl->crl, "tbsCertList", + &crl_signed_data); if (result < 0) { MHD_gnutls_assert (); goto cleanup; } - result = MHD__gnutls_x509_get_signature (crl->crl, "signature", &crl_signature); + result = + MHD__gnutls_x509_get_signature (crl->crl, "signature", &crl_signature); if (result < 0) { MHD_gnutls_assert (); @@ -966,7 +976,8 @@ MHD__gnutls_verify_crl2 (MHD_gnutls_x509_crl_t crl, } ret = - MHD__gnutls_x509_verify_signature (&crl_signed_data, &crl_signature, issuer); + MHD__gnutls_x509_verify_signature (&crl_signed_data, &crl_signature, + issuer); if (ret < 0) { MHD_gnutls_assert (); diff --git a/src/daemon/internal.c b/src/daemon/internal.c @@ -128,9 +128,7 @@ MHD_http_unescape (char *val) while (NULL != (esc = strstr (val, "%"))) { if ((1 == SSCANF (&esc[1], - "%2x", &num)) || - (1 == SSCANF (&esc[1], - "%2X", &num))) + "%2x", &num)) || (1 == SSCANF (&esc[1], "%2X", &num))) { esc[0] = (unsigned char) num; memmove (&esc[1], &esc[3], strlen (&esc[3]) + 1); diff --git a/src/daemon/internal.h b/src/daemon/internal.h @@ -313,9 +313,8 @@ char *MHD_state_to_string (enum MHD_CONNECTION_STATE state); * @param max_bytes maximum number of bytes to receive * @return number of bytes written to write_to */ -typedef ssize_t (*ReceiveCallback)(struct MHD_Connection * conn, - void * write_to, - size_t max_bytes); +typedef ssize_t (*ReceiveCallback) (struct MHD_Connection * conn, + void *write_to, size_t max_bytes); /** @@ -326,9 +325,8 @@ typedef ssize_t (*ReceiveCallback)(struct MHD_Connection * conn, * @param max_bytes maximum number of bytes to transmit * @return number of bytes transmitted */ -typedef ssize_t (*TransmitCallback)(struct MHD_Connection * conn, - const void * write_to, - size_t max_bytes); +typedef ssize_t (*TransmitCallback) (struct MHD_Connection * conn, + const void *write_to, size_t max_bytes); diff --git a/src/examples/https_fileserver_example.c b/src/examples/https_fileserver_example.c @@ -157,33 +157,33 @@ main (int argc, char *const *argv) { struct MHD_Daemon *TLS_daemon; - if (argc == 3){ - /* TODO check if this is truly necessary - disallow usage of the blocking /dev/random */ - /* gcry_control(GCRYCTL_ENABLE_QUICK_RANDOM, 0); */ - TLS_daemon = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_DEBUG - | MHD_USE_SSL, atoi (argv[1]), - NULL, - NULL, &http_ahc, - NULL, MHD_OPTION_CONNECTION_TIMEOUT, 256, - MHD_OPTION_HTTPS_MEM_KEY, key_pem, - MHD_OPTION_HTTPS_MEM_CERT, cert_pem, - - MHD_OPTION_END); - } - else { - printf - ("Usage : %s HTTP-PORT SECONDS-TO-RUN\n", argv[0]); - return 1; - } + if (argc == 3) + { + /* TODO check if this is truly necessary - disallow usage of the blocking /dev/random */ + /* gcry_control(GCRYCTL_ENABLE_QUICK_RANDOM, 0); */ + TLS_daemon = + MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_DEBUG | + MHD_USE_SSL, atoi (argv[1]), NULL, NULL, &http_ahc, + NULL, MHD_OPTION_CONNECTION_TIMEOUT, 256, + MHD_OPTION_HTTPS_MEM_KEY, key_pem, + MHD_OPTION_HTTPS_MEM_CERT, cert_pem, + MHD_OPTION_END); + } + else + { + printf ("Usage: %s HTTP-PORT SECONDS-TO-RUN\n", argv[0]); + return 1; + } if (TLS_daemon == NULL) { - printf ("Error: failed to start TLS_daemon"); + fprintf (stderr, "Error: failed to start TLS_daemon\n"); return 1; } - else { - printf ("MHD daemon listening on port %d\n", atoi (argv[1])); - } + else + { + printf ("MHD daemon listening on port %d\n", atoi (argv[1])); + } sleep (atoi (argv[2])); diff --git a/src/examples/refuse_post_example.c b/src/examples/refuse_post_example.c @@ -24,7 +24,7 @@ #include "platform.h" #include <microhttpd.h> -const char* askpage = "<html><body>\n\ +const char *askpage = "<html><body>\n\ Upload a file, please!<br>\n\ <form action=\"/filepost\" method=\"post\" enctype=\"multipart/form-data\">\n\ <input name=\"file\" type=\"file\">\n\ @@ -48,20 +48,23 @@ ahc_echo (void *cls, if ((0 != strcmp (method, "GET")) && (0 != strcmp (method, "POST"))) return MHD_NO; /* unexpected method */ - + if (&aptr != *ptr) { *ptr = &aptr; /* always to busy for POST requests */ if (0 == strcmp (method, "POST")) - { - response = MHD_create_response_from_data (strlen (BUSYPAGE), - (void *) BUSYPAGE, MHD_NO, MHD_NO); - ret = MHD_queue_response (connection, MHD_HTTP_SERVICE_UNAVAILABLE, response); - MHD_destroy_response (response); - return ret; - } + { + response = MHD_create_response_from_data (strlen (BUSYPAGE), + (void *) BUSYPAGE, MHD_NO, + MHD_NO); + ret = + MHD_queue_response (connection, MHD_HTTP_SERVICE_UNAVAILABLE, + response); + MHD_destroy_response (response); + return ret; + } } *ptr = NULL; /* reset when done */ @@ -84,7 +87,8 @@ main (int argc, char *const *argv) } d = MHD_start_daemon (MHD_USE_THREAD_PER_CONNECTION | MHD_USE_DEBUG, atoi (argv[1]), - NULL, NULL, &ahc_echo, (void *) askpage, MHD_OPTION_END); + NULL, NULL, &ahc_echo, (void *) askpage, + MHD_OPTION_END); if (d == NULL) return 1; sleep (atoi (argv[2])); diff --git a/src/include/microhttpd.h b/src/include/microhttpd.h @@ -547,7 +547,7 @@ enum MHD_GNUTLS_CredentialsType * We have a x.509 certificate. */ MHD_GNUTLS_CRD_CERTIFICATE = 1, - + /** * We have no certificate ("anonymous"). */ @@ -579,8 +579,8 @@ enum MHD_GNUTLS_HashAlgorithm MHD_GNUTLS_MAC_SHA1, MHD_GNUTLS_MAC_SHA256 #if 0 - /* unsupported */ - MHD_GNUTLS_MAC_SHA384, + /* unsupported */ + MHD_GNUTLS_MAC_SHA384, MHD_GNUTLS_MAC_SHA512 #endif }; @@ -592,7 +592,7 @@ enum MHD_GNUTLS_HashAlgorithm */ enum MHD_GNUTLS_CompressionMethod { - MHD_GNUTLS_COMP_UNKNOWN = 0, + MHD_GNUTLS_COMP_UNKNOWN = 0, /** * No compression. @@ -639,8 +639,8 @@ enum MHD_GNUTLS_PublicKeyAlgorithm MHD_GNUTLS_PK_UNKNOWN = 0, MHD_GNUTLS_PK_RSA = 1 #if 0 - /* unsupported */ - MHD_GNUTLS_PK_DSA + /* unsupported */ + MHD_GNUTLS_PK_DSA #endif }; @@ -962,7 +962,7 @@ void MHD_stop_daemon (struct MHD_Daemon *daemon); * @param daemon daemon to get sets from * @param read_fd_set read set * @param write_fd_set write set - * @param except_fd_set except set + * @param except_fd_set except set * @param max_fd increased to largest FD added (if larger * than existing value) * @return MHD_YES on success, MHD_NO if this @@ -979,7 +979,7 @@ MHD_get_fdset (struct MHD_Daemon *daemon, * (only needed if connection timeout is used). The * returned value is how long select should at most * block, not the timeout value set for connections. - * + * * @param daemon daemon to query for timeout * @param timeout set to the timeout (in milliseconds) * @return MHD_YES on success, MHD_NO if timeouts are diff --git a/src/testcurl/https/mhds_session_info_test.c b/src/testcurl/https/mhds_session_info_test.c @@ -70,24 +70,24 @@ query_session_ahc (void *cls, struct MHD_Connection *connection, int ret; /* assert actual connection cipher is the one negotiated */ - if (MHD_get_connection_info (connection, MHD_CONNECTION_INFO_CIPHER_ALGO)->cipher_algorithm - != MHD_GNUTLS_CIPHER_AES_256_CBC) + if (MHD_get_connection_info (connection, MHD_CONNECTION_INFO_CIPHER_ALGO)-> + cipher_algorithm != MHD_GNUTLS_CIPHER_AES_256_CBC) { fprintf (stderr, "Error: requested cipher mismatch. %s\n", strerror (errno)); return -1; } - if (MHD_get_connection_info (connection, MHD_CONNECTION_INFO_KX_ALGO)->kx_algorithm != - MHD_GNUTLS_KX_RSA) + if (MHD_get_connection_info (connection, MHD_CONNECTION_INFO_KX_ALGO)-> + kx_algorithm != MHD_GNUTLS_KX_RSA) { fprintf (stderr, "Error: requested key exchange mismatch. %s\n", strerror (errno)); return -1; } - if (MHD_get_connection_info (connection, MHD_CONNECTION_INFO_MAC_ALGO)->mac_algorithm != - MHD_GNUTLS_MAC_SHA1) + if (MHD_get_connection_info (connection, MHD_CONNECTION_INFO_MAC_ALGO)-> + mac_algorithm != MHD_GNUTLS_MAC_SHA1) { fprintf (stderr, "Error: requested mac algorithm mismatch. %s\n", strerror (errno)); @@ -104,16 +104,16 @@ query_session_ahc (void *cls, struct MHD_Connection *connection, return -1; } - if (MHD_get_connection_info (connection, MHD_CONNECTION_INFO_PROTOCOL)->protocol != - MHD_GNUTLS_PROTOCOL_SSL3) + if (MHD_get_connection_info (connection, MHD_CONNECTION_INFO_PROTOCOL)-> + protocol != MHD_GNUTLS_PROTOCOL_SSL3) { fprintf (stderr, "Error: requested compression mismatch. %s\n", strerror (errno)); return -1; } - if (MHD_get_connection_info (connection, MHD_CONNECTION_INFO_CERT_TYPE)->certificate_type - != MHD_GNUTLS_CRT_X509) + if (MHD_get_connection_info (connection, MHD_CONNECTION_INFO_CERT_TYPE)-> + certificate_type != MHD_GNUTLS_CRT_X509) { fprintf (stderr, "Error: requested certificate mismatch. %s\n", strerror (errno));