Commit d6073e27 authored by FdaSilvaYY's avatar FdaSilvaYY Committed by Matt Caswell
Browse files

Small nits and cleanups



using util/openssl-format-source on s_derver, s_client, ca.c, speed.c only...

Fix/merge some #ifndef

Reviewed-by: default avatarRich Salz <rsalz@openssl.org>
Reviewed-by: default avatarMatt Caswell <matt@openssl.org>
parent cc696296
Loading
Loading
Loading
Loading
+24 −25
Original line number Diff line number Diff line
@@ -132,7 +132,6 @@ static void do_ssl_shutdown(SSL *ssl)
    } while (ret < 0);
}


#ifndef OPENSSL_NO_PSK
/* Default PSK identity and key */
static char *psk_identity = "Client_identity";
@@ -542,7 +541,8 @@ typedef enum OPTION_choice {
    OPT_SSL3, OPT_SSL_CONFIG,
    OPT_TLS1_2, OPT_TLS1_1, OPT_TLS1, OPT_DTLS, OPT_DTLS1,
    OPT_DTLS1_2, OPT_TIMEOUT, OPT_MTU, OPT_KEYFORM, OPT_PASS,
    OPT_CERT_CHAIN, OPT_CAPATH, OPT_NOCAPATH, OPT_CHAINCAPATH, OPT_VERIFYCAPATH,
    OPT_CERT_CHAIN, OPT_CAPATH, OPT_NOCAPATH, OPT_CHAINCAPATH,
        OPT_VERIFYCAPATH,
    OPT_KEY, OPT_RECONNECT, OPT_BUILD_CHAIN, OPT_CAFILE, OPT_NOCAFILE,
    OPT_CHAINCAFILE, OPT_VERIFYCAFILE, OPT_NEXTPROTONEG, OPT_ALPN,
    OPT_SERVERINFO, OPT_STARTTLS, OPT_SERVERNAME,
@@ -906,8 +906,8 @@ int s_client_main(int argc, char **argv)
        if (IS_NO_PROT_FLAG(o))
            no_prot_opt++;
        if (prot_opt == 1 && no_prot_opt) {
            BIO_printf(bio_err, "Cannot supply both a protocol flag and "
                                "\"-no_<prot>\"\n");
            BIO_printf(bio_err,
                       "Cannot supply both a protocol flag and '-no_<prot>'\n");
            goto end;
        }

@@ -1335,8 +1335,8 @@ int s_client_main(int argc, char **argv)
        if (tmp_port != port)
            OPENSSL_free(tmp_port);
        if (!res) {
            BIO_printf(bio_err, "%s: -proxy argument malformed or ambiguous\n",
                       prog);
            BIO_printf(bio_err,
                       "%s: -proxy argument malformed or ambiguous\n", prog);
            goto end;
        }
    } else {
@@ -1529,8 +1529,7 @@ int s_client_main(int argc, char **argv)
#ifndef OPENSSL_NO_PSK
    if (psk_key != NULL) {
        if (c_debug)
            BIO_printf(bio_c_out,
                       "PSK key given, setting client callback\n");
            BIO_printf(bio_c_out, "PSK key given, setting client callback\n");
        SSL_CTX_set_psk_client_callback(ctx, psk_client_cb);
    }
#endif
@@ -1643,7 +1642,8 @@ int s_client_main(int argc, char **argv)
    if (dane_tlsa_domain != NULL) {
        if (SSL_CTX_dane_enable(ctx) <= 0) {
            BIO_printf(bio_err,
                       "%s: Error enabling DANE TLSA authentication.\n", prog);
                       "%s: Error enabling DANE TLSA authentication.\n",
                       prog);
            ERR_print_errors(bio_err);
            goto end;
        }
@@ -1708,8 +1708,7 @@ int s_client_main(int argc, char **argv)
    }

 re_start:
    if (init_client(&s, host, port, socket_family, socket_type) == 0)
    {
    if (init_client(&s, host, port, socket_family, socket_type) == 0) {
        BIO_printf(bio_err, "connect:errno=%d\n", get_last_socket_error());
        BIO_closesocket(s);
        goto end;
@@ -2573,7 +2572,8 @@ static void print_stuff(BIO *bio, SSL *s, int full)
#endif

        BIO_printf(bio,
                   "---\nSSL handshake has read %"PRIu64" bytes and written %"PRIu64" bytes\n",
                   "---\nSSL handshake has read %" PRIu64
                   " bytes and written %" PRIu64 " bytes\n",
                   BIO_number_read(SSL_get_rbio(s)),
                   BIO_number_written(SSL_get_wbio(s)));
    }
@@ -2650,8 +2650,7 @@ static void print_stuff(BIO *bio, SSL *s, int full)
#endif

    SSL_SESSION_print(bio, SSL_get_session(s));
    if ((SSL_get_session(s) != NULL) &&
        (keymatexportlabel != NULL)) {
    if (SSL_get_session(s) != NULL && keymatexportlabel != NULL) {
        BIO_printf(bio, "Keying material exporter:\n");
        BIO_printf(bio, "    Label: '%s'\n", keymatexportlabel);
        BIO_printf(bio, "    Length: %i bytes\n", keymatexportlen);
+35 −30
Original line number Diff line number Diff line
@@ -796,12 +796,12 @@ OPTIONS s_server_options[] = {
     "Print output from SSL/TLS security framework"},
    {"security_debug_verbose", OPT_SECURITY_DEBUG_VERBOSE, '-',
     "Print more output from SSL/TLS security framework"},
    {"brief", OPT_BRIEF, '-', \
    {"brief", OPT_BRIEF, '-',
     "Restrict output to brief summary of connection parameters"},
    {"rev", OPT_REV, '-',
     "act as a simple test server which just sends back with the received text reversed"},
    {"async", OPT_ASYNC, '-', "Operate in asynchronous mode"},
    {"ssl_config", OPT_SSL_CONFIG, 's', \
    {"ssl_config", OPT_SSL_CONFIG, 's',
     "Configure SSL_CTX using the configuration 'val'"},
    {"split_send_frag", OPT_SPLIT_SEND_FRAG, 'n',
     "Size used to split data for encrypt pipelines"},
@@ -954,7 +954,8 @@ int s_server_main(int argc, char *argv[])
    vpm = X509_VERIFY_PARAM_new();
    if (cctx == NULL || vpm == NULL)
        goto end;
    SSL_CONF_CTX_set_flags(cctx, SSL_CONF_FLAG_SERVER | SSL_CONF_FLAG_CMDLINE);
    SSL_CONF_CTX_set_flags(cctx,
                           SSL_CONF_FLAG_SERVER | SSL_CONF_FLAG_CMDLINE);

    prog = opt_init(argc, argv, s_server_options);
    while ((o = opt_next()) != OPT_EOF) {
@@ -965,8 +966,8 @@ int s_server_main(int argc, char *argv[])
        if (IS_NO_PROT_FLAG(o))
            no_prot_opt++;
        if (prot_opt == 1 && no_prot_opt) {
            BIO_printf(bio_err, "Cannot supply both a protocol flag and "
                                "\"-no_<prot>\"\n");
            BIO_printf(bio_err,
                       "Cannot supply both a protocol flag and '-no_<prot>'\n");
            goto end;
        }
        switch (o) {
@@ -1659,7 +1660,6 @@ int s_server_main(int argc, char *argv[])
    if (read_buf_len > 0) {
        SSL_CTX_set_default_read_buffer_len(ctx, read_buf_len);
    }

#ifndef OPENSSL_NO_SRTP
    if (srtp_profiles != NULL) {
        /* Returns 0 on success! */
@@ -1834,8 +1834,7 @@ int s_server_main(int argc, char *argv[])
#ifndef OPENSSL_NO_PSK
    if (psk_key != NULL) {
        if (s_debug)
            BIO_printf(bio_s_out,
                       "PSK key given, setting server callback\n");
            BIO_printf(bio_s_out, "PSK key given, setting server callback\n");
        SSL_CTX_set_psk_server_callback(ctx, psk_server_cb);
    }

@@ -2465,7 +2464,8 @@ static int init_ssl_connection(SSL *con)
            retry = BIO_sock_should_retry(i);
#ifdef CERT_CB_TEST_RETRY
        {
            while (i <= 0 && SSL_get_error(con, i) == SSL_ERROR_WANT_X509_LOOKUP
            while (i <= 0
                    && SSL_get_error(con, i) == SSL_ERROR_WANT_X509_LOOKUP
                    && SSL_get_state(con) == TLS_ST_SR_CLNT_HELLO) {
                BIO_printf(bio_err,
                           "LOOKUP from certificate callback during accept\n");
@@ -2477,7 +2477,8 @@ static int init_ssl_connection(SSL *con)
#endif

#ifndef OPENSSL_NO_SRP
        while (i <= 0 && SSL_get_error(con, i) == SSL_ERROR_WANT_X509_LOOKUP) {
        while (i <= 0
               && SSL_get_error(con, i) == SSL_ERROR_WANT_X509_LOOKUP) {
            BIO_printf(bio_s_out, "LOOKUP during accept %s\n",
                       srp_callback_parm.login);
            SRP_user_pwd_free(srp_callback_parm.user);
@@ -2645,7 +2646,8 @@ static int www_body(int s, int stype, unsigned char *context)
        SSL_set_tlsext_debug_arg(con, bio_s_out);
    }

    if (context && !SSL_set_session_id_context(con, context,
    if (context
        && !SSL_set_session_id_context(con, context,
                                       strlen((char *)context)))
        goto err;

@@ -2743,7 +2745,8 @@ static int www_body(int s, int stype, unsigned char *context)
                openssl_fdset(s, &readfds);
                i = select(width, (void *)&readfds, NULL, NULL, NULL);
                if (i <= 0 || !FD_ISSET(s, &readfds)) {
                    BIO_printf(bio_s_out, "Error waiting for client response\n");
                    BIO_printf(bio_s_out,
                               "Error waiting for client response\n");
                    ERR_print_errors(bio_err);
                    goto err;
                }
@@ -2949,7 +2952,8 @@ static int www_body(int s, int stype, unsigned char *context)
#endif
                    k = BIO_write(io, &(buf[j]), i - j);
                    if (k <= 0) {
                        if (!BIO_should_retry(io)  && !SSL_waiting_for_async(con))
                        if (!BIO_should_retry(io)
                            && !SSL_waiting_for_async(con))
                            goto write_error;
                        else {
                            BIO_printf(bio_s_out, "rwrite W BLOCK\n");
@@ -3011,7 +3015,8 @@ static int rev_body(int s, int stype, unsigned char *context)
        SSL_set_tlsext_debug_arg(con, bio_s_out);
    }
    if (context
        && !SSL_set_session_id_context(con, context, strlen((char *)context))) {
        && !SSL_set_session_id_context(con, context,
                                       strlen((char *)context))) {
        ERR_print_errors(bio_err);
        goto err;
    }
+14 −19
Original line number Diff line number Diff line
@@ -380,7 +380,8 @@ OPTIONS speed_options[] = {
    {"multi", OPT_MULTI, 'p', "Run benchmarks in parallel"},
#endif
#ifndef OPENSSL_NO_ASYNC
    {"async_jobs", OPT_ASYNCJOBS, 'p', "Enable async mode and start pnum jobs"},
    {"async_jobs", OPT_ASYNCJOBS, 'p',
     "Enable async mode and start pnum jobs"},
#endif
#ifndef OPENSSL_NO_ENGINE
    {"engine", OPT_ENGINE, 's', "Use engine, possibly a hardware device"},
@@ -430,8 +431,6 @@ static OPT_PAIR doit_choices[] = {
#endif
#ifndef OPENSSL_NO_MD5
    {"md5", D_MD5},
#endif
#ifndef OPENSSL_NO_MD5
    {"hmac", D_HMAC},
#endif
    {"sha1", D_SHA1},
@@ -555,6 +554,7 @@ static OPT_PAIR ecdsa_choices[] = {
    {"ecdsab571", R_EC_B571},
    {NULL}
};

static OPT_PAIR ecdh_choices[] = {
    {"ecdhp160", R_EC_P160},
    {"ecdhp192", R_EC_P192},
@@ -1067,8 +1067,7 @@ static void *KDF1_SHA1(const void *in, size_t inlen, void *out,
    *outlen = SHA_DIGEST_LENGTH;
    return SHA1(in, inlen, out);
}
#endif      /* ndef OPENSSL_NO_EC */

#endif                          /* OPENSSL_NO_EC */

static int run_benchmark(int async_jobs,
                         int (*loop_function)(void *), loopargs_t *loopargs)
@@ -1571,8 +1570,10 @@ int speed_main(int argc, char **argv)
        for (i = 0; i < ALGOR_NUM; i++)
            if (i != D_EVP)
                doit[i] = 1;
#ifndef OPENSSL_NO_RSA
        for (i = 0; i < RSA_NUM; i++)
            rsa_doit[i] = 1;
#endif
#ifndef OPENSSL_NO_DSA
        for (i = 0; i < DSA_NUM; i++)
            dsa_doit[i] = 1;
@@ -1901,11 +1902,9 @@ int speed_main(int argc, char **argv)
            print_result(D_MD5, testnum, count, d);
        }
    }
#endif

#ifndef OPENSSL_NO_MD5
    if (doit[D_HMAC]) {
        char hmac_key[] = "This is a key...";
        static const char hmac_key[] = "This is a key...";
        int len = strlen(hmac_key);

        for (i = 0; i < loopargs_len; i++) {
@@ -2372,7 +2371,7 @@ int speed_main(int argc, char **argv)
                rsa_doit[testnum] = 0;
        }
    }
#endif
#endif                          /* OPENSSL_NO_RSA */

    for (i = 0; i < loopargs_len; i++)
        RAND_bytes(loopargs[i].buf, 36);
@@ -2443,7 +2442,7 @@ int speed_main(int argc, char **argv)
                dsa_doit[testnum] = 0;
        }
    }
#endif
#endif                          /* OPENSSL_NO_DSA */

#ifndef OPENSSL_NO_EC
    if (RAND_status() != 1) {
@@ -2625,7 +2624,7 @@ int speed_main(int argc, char **argv)
                ecdh_doit[testnum] = 0;
        }
    }
#endif
#endif                          /* OPENSSL_NO_EC */
#ifndef NO_FORK
 show_res:
#endif
@@ -2997,11 +2996,7 @@ static int do_multi(int multi)
                        1 / (1 / ecdsa_results[k][1] + 1 / d);
                else
                    ecdsa_results[k][1] = d;
            }
# endif

# ifndef OPENSSL_NO_EC
            else if (strncmp(buf, "+F5:", 4) == 0) {
            } else if (strncmp(buf, "+F5:", 4) == 0) {
                int k;
                double d;

+2 −2

File changed.

Contains only whitespace changes.