From: Georgios Kontaxis Date: Tue, 15 May 2018 22:41:31 +0000 (-0700) Subject: Indentation adjustments. X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=12a9d6c1e39a8b20515867a84d98f15628f54e82;p=starttls.git Indentation adjustments. --- diff --git a/scan/src/aux.h b/scan/src/aux.h index bb57978..b3251b1 100644 --- a/scan/src/aux.h +++ b/scan/src/aux.h @@ -10,25 +10,25 @@ */ ssize_t read_bytes(int fd, void *buf, size_t count) { - size_t i = 0; - ssize_t r; + size_t i = 0; + ssize_t r; - while (i < count) { - r = read(fd, buf + i, count - i); - if (r == 0 || r == -1) { + while (i < count) { + r = read(fd, buf + i, count - i); + if (r == 0 || r == -1) { if (r == 0) { #if __DEBUG__ fprintf(stderr, "EOF or peer has performed socket shutdown.\n"); #endif } else { - perror("read"); + perror("read"); } - return r; - } - i += r; - } + return r; + } + i += r; + } - return count; + return count; } #endif diff --git a/scan/src/ciphersuites.h b/scan/src/ciphersuites.h index 240c115..64b3dcd 100644 --- a/scan/src/ciphersuites.h +++ b/scan/src/ciphersuites.h @@ -41,17 +41,17 @@ /* Fallback to TLS 1.2 */ #if NO(__SSL_3_0__) &&\ - NO(__TLS_1_0__) &&\ + NO(__TLS_1_0__) &&\ NO(__RFC2712__) &&\ NO(__RFC3268__) &&\ NO(__DFTXP56__) &&\ NO(__RFC4132__) &&\ NO(__RFC4162__) &&\ NO(__RFC4279__) &&\ - NO(__TLS_1_1__) &&\ + NO(__TLS_1_1__) &&\ NO(__RFC4492__) &&\ NO(__RFC5054__) &&\ - NO(__TLS_1_2__) &&\ + NO(__TLS_1_2__) &&\ NO(__RFC5288__) &&\ NO(__RFC5289__) &&\ NO(__RFC5932__) &&\ @@ -149,10 +149,10 @@ /* Version-specific definitions */ /* SSL 3.0 */ -#if YES(__SSL_3_0__) &&\ - NO(__TLS_1_0__) &&\ - NO(__TLS_1_1__) &&\ - NO(__TLS_1_2__) +#if YES(__SSL_3_0__) &&\ + NO(__TLS_1_0__) &&\ + NO(__TLS_1_1__) &&\ + NO(__TLS_1_2__) #undef PROTOCOLMAJOR #undef PROTOCOLMINOR #define PROTOCOLMAJOR 3 @@ -161,9 +161,9 @@ #define CIPHERSUITEMANDATORY 0x0000 /* TLS_NULL_WITH_NULL_NULL */ /* TLS 1.0 */ #elif NO(__SSL_3_0__) &&\ - YES(__TLS_1_0__) &&\ - NO(__TLS_1_1__) &&\ - NO(__TLS_1_2__) + YES(__TLS_1_0__) &&\ + NO(__TLS_1_1__) &&\ + NO(__TLS_1_2__) #undef PROTOCOLMAJOR #undef PROTOCOLMINOR #define PROTOCOLMAJOR 3 @@ -185,9 +185,9 @@ #define CIPHERSUITEMANDATORY 0x0013 /* TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA */ /* TLS 1.1 */ #elif NO(__SSL_3_0__) &&\ - NO(__TLS_1_0__) &&\ - YES(__TLS_1_1__) &&\ - NO(__TLS_1_2__) + NO(__TLS_1_0__) &&\ + YES(__TLS_1_1__) &&\ + NO(__TLS_1_2__) #undef PROTOCOLMAJOR #undef PROTOCOLMINOR #define PROTOCOLMAJOR 3 @@ -202,9 +202,9 @@ #define CIPHERSUITEMANDATORY 0x000A /* TLS_RSA_WITH_3DES_EDE_CBC_SHA */ /* TLS 1.2 */ #elif NO(__SSL_3_0__) &&\ - NO(__TLS_1_0__) &&\ - NO(__TLS_1_1__) &&\ - YES(__TLS_1_2__) + NO(__TLS_1_0__) &&\ + NO(__TLS_1_1__) &&\ + YES(__TLS_1_2__) #undef PROTOCOLMAJOR #undef PROTOCOLMINOR #define PROTOCOLMAJOR 3 diff --git a/scan/src/smtp.c b/scan/src/smtp.c index d84a6ec..eb06e94 100644 --- a/scan/src/smtp.c +++ b/scan/src/smtp.c @@ -332,23 +332,23 @@ int open_dump_file (char * opt_dump_dir, uint16_t suite) } /* Open file descriptor to dump entire TLS conversation */ - char *s = strdup(tls_suite_name(suite)); - for (r = strlen(s) - 1; r >= 0 && isspace(s[r]); r--) { - s[r] = '\0'; - } - char tls_out_filename[0xFFFF]; /* should be enough :D */ - snprintf(tls_out_filename, sizeof(tls_out_filename), - "%s/%s.%u.%u.0x%04x_%s", opt_dump_dir, "ssl", + char *s = strdup(tls_suite_name(suite)); + for (r = strlen(s) - 1; r >= 0 && isspace(s[r]); r--) { + s[r] = '\0'; + } + char tls_out_filename[0xFFFF]; /* should be enough :D */ + snprintf(tls_out_filename, sizeof(tls_out_filename), + "%s/%s.%u.%u.0x%04x_%s", opt_dump_dir, "ssl", (uint8_t) tls_suite_version_major(), - (uint8_t) tls_suite_version_minor(), (uint16_t) suite, s); - if (s) { - free(s); - } + (uint8_t) tls_suite_version_minor(), (uint16_t) suite, s); + if (s) { + free(s); + } if ((r = open(tls_out_filename, O_CREAT | O_RDWR | O_TRUNC, - S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)) == -1) { - perror("open"); - } + S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)) == -1) { + perror("open"); + } return r; } @@ -571,7 +571,7 @@ int main(int argc, char**argv) /* If specific ciphersuites have been specified, do only use those. * Else, go over all ciphersuites assuming the target supports STARTTLS. - * Abort on SMTP error. */ + * Abort on SMTP error. */ for (x = 0; x < CipherSuite_count; x++) { /* Set ciphersuite(s) to be used */ tls_init(); diff --git a/scan/src/tls.c b/scan/src/tls.c index af593f6..ec41340 100644 --- a/scan/src/tls.c +++ b/scan/src/tls.c @@ -84,7 +84,7 @@ int tls_process_Handshake_ClientHello() must_read_bytes = n24toh32(tls_Handshake_header.Handshake__length); /* Read up to the session ID length byte. Since the session ID - * is of variable length we need to figure out how much to read as such. */ + * is of variable length we need to figure out how much to read as such. */ if (read_bytes(tls_in, &tls_ClientHello_intro, sizeof(tls_ClientHello_intro)) <= 0) { @@ -141,7 +141,7 @@ int tls_process_Handshake_ClientHello() } } - /* Now we know we must read session_id_length bytes */ + /* Now we know we must read session_id_length bytes */ assert(tls_ClientHello_session.session_id_length <= sizeof(tls_ClientHello_session.session_id)); @@ -391,7 +391,7 @@ int tls_process_Handshake_ServerHello() must_read_bytes = n24toh32(tls_Handshake_header.Handshake__length); /* Read up to the session ID length byte. Since the session ID - * is of variable length we need to figure out how much to read as such. */ + * is of variable length we need to figure out how much to read as such. */ if (read_bytes(tls_in, &tls_ServerHello_intro, sizeof(tls_ServerHello_intro)) <= 0) { @@ -453,7 +453,7 @@ int tls_process_Handshake_ServerHello() } } - /* Now we know we must read session_id_length bytes */ + /* Now we know we must read session_id_length bytes */ assert(tls_ServerHello_session.session_id_length <= sizeof(tls_ServerHello_session.session_id)); @@ -1004,10 +1004,10 @@ int _tls() n24toh32(tls_Handshake_header.Handshake__length)); #endif - /* The record layer fragments information blocks (e.g., handshake + /* The record layer fragments information blocks (e.g., handshake * messages or application data) into TLSPlaintext records carrying * data in chunks of 2^14 bytes or less.*/ - assert(ntohs(tls_TLSPlaintext_header.TLSPlaintext__length) <= 0x4000); + assert(ntohs(tls_TLSPlaintext_header.TLSPlaintext__length) <= 0x4000); #if 1 /* We can't handle fragmentation right now. @@ -1528,14 +1528,14 @@ int tls_error() void tls_print_suites() { - uint16_t i; - - for (i = 0; i < CIPHERSUITES; i++) { - fprintf(stderr, - "%3u CipherSuite %s = { 0x%02X,0x%02X };\n", - CipherSuites[i], CIPHER_TXT(CipherSuites[i]), - CipherSuites[i] >> 8, CipherSuites[i] & 0xFF); - } + uint16_t i; + + for (i = 0; i < CIPHERSUITES; i++) { + fprintf(stderr, + "%3u CipherSuite %s = { 0x%02X,0x%02X };\n", + CipherSuites[i], CIPHER_TXT(CipherSuites[i]), + CipherSuites[i] >> 8, CipherSuites[i] & 0xFF); + } } CipherSuite * tls_suites() @@ -1555,9 +1555,9 @@ const char * tls_suite_name(uint16_t n) void tls_print_version() { - fprintf(stderr, "SSL/TLS protocol_version:%u.%u\n", - PROTOCOLMAJOR, PROTOCOLMINOR); - fprintf(stderr, "Available cipher_suites:%u\n", CIPHERSUITES); + fprintf(stderr, "SSL/TLS protocol_version:%u.%u\n", + PROTOCOLMAJOR, PROTOCOLMINOR); + fprintf(stderr, "Available cipher_suites:%u\n", CIPHERSUITES); } uint8_t tls_stat_flags (void) diff --git a/scan/src/tls.h b/scan/src/tls.h index 666fcfa..2cddcd7 100644 --- a/scan/src/tls.h +++ b/scan/src/tls.h @@ -285,7 +285,7 @@ const char * tls_HashAlgorithmNames[TLS_HASH_ALGORITHMS_MAX + 1] = { }; #define TLS_HASH_ALGORITHM_TXT(n) \ - (((n) >= 0 && (n) <= TLS_HASH_ALGORITHMS_MAX) ? \ + (((n) >= 0 && (n) <= TLS_HASH_ALGORITHMS_MAX) ? \ tls_HashAlgorithmNames[(n)] : "ERR_NOT_IMPLEMENTED") #define TLS_SIGNATURE_ALGORITHMS_MAX 3 @@ -298,7 +298,7 @@ const char * tls_SignatureAlgorithmNames[TLS_SIGNATURE_ALGORITHMS_MAX + 1] = { }; #define TLS_SIGNATURE_ALGORITHM_TXT(n) \ - (((n) >= 0 && (n) <= TLS_SIGNATURE_ALGORITHMS_MAX) ? \ + (((n) >= 0 && (n) <= TLS_SIGNATURE_ALGORITHMS_MAX) ? \ tls_SignatureAlgorithmNames[(n)] : "ERR_NOT_IMPLEMENTED") struct __attribute__((__packed__)) diff --git a/scan/src/tls_api.h b/scan/src/tls_api.h index 37311ae..9bb78b7 100644 --- a/scan/src/tls_api.h +++ b/scan/src/tls_api.h @@ -45,13 +45,13 @@ struct __attribute__((__packed__)) Signature { #define SERVER_KEYEXCHANGE_UNKNOWN 0x0 #define SERVER_KEYEXCHANGE_DHPARAMS 0x7 struct __attribute__((__packed__)) ServerKeyExchange_DHparams { - struct ServerDHParams *params; + struct ServerDHParams *params; }; #define SERVER_KEYEXCHANGE_DHPARAMS_SIGNATURE (\ 0x3 | SERVER_KEYEXCHANGE_DHPARAMS) struct __attribute__((__packed__)) ServerKeyExchange_DHparams_signature { - struct ServerDHParams *params; - struct DigitallySigned *signed_params; + struct ServerDHParams *params; + struct DigitallySigned *signed_params; }; int tls_set_callback_handshake_server_key_exchange (int (*handler)( uint8_t *ServerKeyExchange, uint32_t ServerKeyExchangeType));