From 61986d32f37cbaeaed08bd955ff27d35b72ea29a Mon Sep 17 00:00:00 2001 From: Viktor Dukhovni Date: Thu, 16 Apr 2015 01:50:03 -0400 Subject: [PATCH] Code style: space after 'if' Reviewed-by: Matt Caswell --- apps/apps.c | 4 +-- apps/ca.c | 10 +++---- apps/cms.c | 2 +- apps/s_cb.c | 4 +-- apps/s_client.c | 10 +++---- apps/s_server.c | 20 ++++++------- apps/s_time.c | 10 +++---- apps/sess_id.c | 2 +- apps/speed.c | 6 ++-- apps/srp.c | 4 +-- crypto/asn1/bio_ndef.c | 4 +-- crypto/asn1/tasn_prn.c | 2 +- crypto/asn1/x_x509.c | 4 +-- crypto/bio/b_print.c | 4 +-- crypto/bio/bss_dgram.c | 4 +-- crypto/cms/cms_pwri.c | 2 +- crypto/dh/dh_ameth.c | 2 +- crypto/dh/dh_pmeth.c | 2 +- crypto/dsa/dsa_ossl.c | 8 +++--- crypto/dso/dso_lib.c | 2 +- crypto/dso/dso_vms.c | 2 +- crypto/hmac/hmac.c | 12 ++++---- crypto/objects/o_names.c | 2 +- crypto/rand/rand_os2.c | 2 +- crypto/threads/th-lock.c | 12 ++++---- crypto/x509v3/v3_cpols.c | 8 +++--- engines/ccgost/gost2001.c | 56 ++++++++++++++++++------------------- engines/ccgost/gost_ameth.c | 18 ++++++------ engines/ccgost/gost_sign.c | 27 +++++++++--------- engines/e_sureware.c | 6 ++-- ssl/bio_ssl.c | 4 +-- ssl/d1_both.c | 2 +- ssl/d1_clnt.c | 2 +- ssl/d1_lib.c | 6 ++-- ssl/d1_srvr.c | 2 +- ssl/record/rec_layer_d1.c | 2 +- ssl/record/rec_layer_s3.c | 8 +++--- ssl/record/ssl3_buffer.c | 2 +- ssl/s23_clnt.c | 4 +-- ssl/s23_srvr.c | 6 ++-- ssl/s3_both.c | 4 +-- ssl/s3_clnt.c | 10 +++---- ssl/s3_enc.c | 6 ++-- ssl/s3_lib.c | 2 +- ssl/s3_srvr.c | 26 ++++++++--------- ssl/ssl_ciph.c | 2 +- ssl/ssl_lib.c | 14 +++++----- ssl/ssl_rsa.c | 2 +- ssl/ssl_sess.c | 4 +-- ssl/ssl_txt.c | 2 +- ssl/t1_enc.c | 4 +-- ssl/t1_lib.c | 2 +- test/hmactest.c | 40 +++++++++++++------------- test/ssltest.c | 30 ++++++++++---------- 54 files changed, 220 insertions(+), 217 deletions(-) diff --git a/apps/apps.c b/apps/apps.c index 65d4e46d57..76e0ee3c13 100644 --- a/apps/apps.c +++ b/apps/apps.c @@ -576,7 +576,7 @@ int password_callback(char *buf, int bufsiz, int verify, PW_CB_DATA *cb_tmp) char *prompt = NULL; prompt = UI_construct_prompt(ui, "pass phrase", prompt_info); - if(!prompt) { + if (!prompt) { BIO_printf(bio_err, "Out of memory\n"); UI_free(ui); return 0; @@ -590,7 +590,7 @@ int password_callback(char *buf, int bufsiz, int verify, PW_CB_DATA *cb_tmp) PW_MIN_LENGTH, bufsiz - 1); if (ok >= 0 && verify) { buff = (char *)OPENSSL_malloc(bufsiz); - if(!buff) { + if (!buff) { BIO_printf(bio_err, "Out of memory\n"); UI_free(ui); OPENSSL_free(prompt); diff --git a/apps/ca.c b/apps/ca.c index 89bece8ed1..e2eab91033 100644 --- a/apps/ca.c +++ b/apps/ca.c @@ -563,7 +563,7 @@ int MAIN(int argc, char **argv) #ifdef OPENSSL_SYS_VMS len = strlen(s) + sizeof(CONFIG_FILE); tofree = OPENSSL_malloc(len); - if(!tofree) { + if (!tofree) { BIO_printf(bio_err, "Out of memory\n"); goto err; } @@ -571,7 +571,7 @@ int MAIN(int argc, char **argv) #else len = strlen(s) + sizeof(CONFIG_FILE) + 1; tofree = OPENSSL_malloc(len); - if(!tofree) { + if (!tofree) { BIO_printf(bio_err, "Out of memory\n"); goto err; } @@ -2808,7 +2808,7 @@ int unpack_revinfo(ASN1_TIME **prevtm, int *preason, ASN1_OBJECT **phold, ASN1_GENERALIZEDTIME *comp_time = NULL; tmp = BUF_strdup(str); - if(!tmp) { + if (!tmp) { BIO_printf(bio_err, "memory allocation failure\n"); goto err; } @@ -2830,7 +2830,7 @@ int unpack_revinfo(ASN1_TIME **prevtm, int *preason, ASN1_OBJECT **phold, if (prevtm) { *prevtm = ASN1_UTCTIME_new(); - if(!*prevtm) { + if (!*prevtm) { BIO_printf(bio_err, "memory allocation failure\n"); goto err; } @@ -2874,7 +2874,7 @@ int unpack_revinfo(ASN1_TIME **prevtm, int *preason, ASN1_OBJECT **phold, goto err; } comp_time = ASN1_GENERALIZEDTIME_new(); - if(!comp_time) { + if (!comp_time) { BIO_printf(bio_err, "memory allocation failure\n"); goto err; } diff --git a/apps/cms.c b/apps/cms.c index 0877426924..73f9037c04 100644 --- a/apps/cms.c +++ b/apps/cms.c @@ -465,7 +465,7 @@ int MAIN(int argc, char **argv) if (key_param == NULL || key_param->idx != keyidx) { cms_key_param *nparam; nparam = OPENSSL_malloc(sizeof(cms_key_param)); - if(!nparam) { + if (!nparam) { BIO_printf(bio_err, "Out of memory\n"); goto argerr; } diff --git a/apps/s_cb.c b/apps/s_cb.c index 7e69fc8f51..06050dbc7c 100644 --- a/apps/s_cb.c +++ b/apps/s_cb.c @@ -460,7 +460,7 @@ int ssl_print_curves(BIO *out, SSL *s, int noshared) if (ncurves <= 0) return 1; curves = OPENSSL_malloc(ncurves * sizeof(int)); - if(!curves) { + if (!curves) { BIO_puts(out, "Malloc error getting supported curves\n"); return 0; } @@ -1181,7 +1181,7 @@ static int set_cert_cb(SSL *ssl, void *arg) print_chain_flags(bio_err, ssl, rv); if (rv & CERT_PKEY_VALID) { - if(!SSL_use_certificate(ssl, exc->cert) + if (!SSL_use_certificate(ssl, exc->cert) || !SSL_use_PrivateKey(ssl, exc->key)) { return 0; } diff --git a/apps/s_client.c b/apps/s_client.c index a7e03a5f33..761f352fe3 100644 --- a/apps/s_client.c +++ b/apps/s_client.c @@ -550,7 +550,7 @@ static char *ssl_give_srp_client_pwd_cb(SSL *s, void *arg) PW_CB_DATA cb_tmp; int l; - if(!pass) { + if (!pass) { BIO_printf(bio_err, "Malloc failure\n"); return NULL; } @@ -1304,7 +1304,7 @@ int MAIN(int argc, char **argv) #ifndef OPENSSL_NO_SRTP if (srtp_profiles != NULL) { /* Returns 0 on success!! */ - if(SSL_CTX_set_tlsext_use_srtp(ctx, srtp_profiles)) { + if (SSL_CTX_set_tlsext_use_srtp(ctx, srtp_profiles)) { BIO_printf(bio_err, "Error setting SRTP profile\n"); ERR_print_errors(bio_err); goto end; @@ -1328,7 +1328,7 @@ int MAIN(int argc, char **argv) goto end; } /* Returns 0 on success!! */ - if(SSL_CTX_set_alpn_protos(ctx, alpn, alpn_len)) { + if (SSL_CTX_set_alpn_protos(ctx, alpn, alpn_len)) { BIO_printf(bio_err, "Error setting ALPN\n"); goto end; } @@ -1337,7 +1337,7 @@ int MAIN(int argc, char **argv) #endif #ifndef OPENSSL_NO_TLSEXT for (i = 0; i < serverinfo_types_count; i++) { - if(!SSL_CTX_add_client_custom_ext(ctx, + if (!SSL_CTX_add_client_custom_ext(ctx, serverinfo_types[i], NULL, NULL, NULL, serverinfo_cli_parse_cb, NULL)) { @@ -1405,7 +1405,7 @@ int MAIN(int argc, char **argv) ERR_print_errors(bio_err); goto end; } - if(!SSL_set_session(con, sess)) { + if (!SSL_set_session(con, sess)) { BIO_printf(bio_err, "Can't set session\n"); ERR_print_errors(bio_err); goto end; diff --git a/apps/s_server.c b/apps/s_server.c index a66098efe7..8e350c89d8 100644 --- a/apps/s_server.c +++ b/apps/s_server.c @@ -707,7 +707,7 @@ static int ebcdic_write(BIO *b, const char *in, int inl) num = inl; wbuf = (EBCDIC_OUTBUFF *) OPENSSL_malloc(sizeof(EBCDIC_OUTBUFF) + num); - if(!wbuf) + if (!wbuf) return 0; OPENSSL_free(b->ptr); @@ -1725,7 +1725,7 @@ int MAIN(int argc, char *argv[]) #ifndef OPENSSL_NO_SRTP if (srtp_profiles != NULL) { /* Returns 0 on success!! */ - if(SSL_CTX_set_tlsext_use_srtp(ctx, srtp_profiles)) { + if (SSL_CTX_set_tlsext_use_srtp(ctx, srtp_profiles)) { BIO_printf(bio_err, "Error setting SRTP profile\n"); ERR_print_errors(bio_err); goto end; @@ -1925,7 +1925,7 @@ int MAIN(int argc, char *argv[]) #endif SSL_CTX_set_verify(ctx, s_server_verify, verify_callback); - if(!SSL_CTX_set_session_id_context(ctx, + if (!SSL_CTX_set_session_id_context(ctx, (void *)&s_server_session_id_context, sizeof s_server_session_id_context)) { BIO_printf(bio_err, "error setting session id context\n"); @@ -1940,7 +1940,7 @@ int MAIN(int argc, char *argv[]) #ifndef OPENSSL_NO_TLSEXT if (ctx2) { SSL_CTX_set_verify(ctx2, s_server_verify, verify_callback); - if(!SSL_CTX_set_session_id_context(ctx2, + if (!SSL_CTX_set_session_id_context(ctx2, (void *)&s_server_session_id_context, sizeof s_server_session_id_context)) { BIO_printf(bio_err, "error setting session id context\n"); @@ -2147,7 +2147,7 @@ static int sv_body(char *hostname, int s, int stype, unsigned char *context) goto err; } } - if(!SSL_clear(con)) { + if (!SSL_clear(con)) { BIO_printf(bio_err, "Error clearing SSL connection\n"); ret = -1; goto err; @@ -3227,7 +3227,7 @@ static int add_session(SSL *ssl, SSL_SESSION *session) unsigned char *p; sess = OPENSSL_malloc(sizeof(simple_ssl_session)); - if(!sess) { + if (!sess) { BIO_printf(bio_err, "Out of memory adding session to external cache\n"); return 0; } @@ -3238,18 +3238,18 @@ static int add_session(SSL *ssl, SSL_SESSION *session) sess->id = BUF_memdup(SSL_SESSION_get_id(session, NULL), sess->idlen); sess->der = OPENSSL_malloc(sess->derlen); - if(!sess->id || !sess->der) { + if (!sess->id || !sess->der) { BIO_printf(bio_err, "Out of memory adding session to external cache\n"); - if(sess->id) + if (sess->id) OPENSSL_free(sess->id); - if(sess->der) + if (sess->der) OPENSSL_free(sess->der); OPENSSL_free(sess); return 0; } p = sess->der; - if(i2d_SSL_SESSION(session, &p) < 0) { + if (i2d_SSL_SESSION(session, &p) < 0) { BIO_printf(bio_err, "Error encoding session\n"); return 0; } diff --git a/apps/s_time.c b/apps/s_time.c index 4f460b6a45..8f4980b677 100644 --- a/apps/s_time.c +++ b/apps/s_time.c @@ -283,7 +283,7 @@ static int parseArgs(int argc, char **argv) if (--argc < 1) goto bad; maxTime = atoi(*(++argv)); - if(maxTime <= 0) { + if (maxTime <= 0) { BIO_printf(bio_err, "time must be > 0\n"); badop = 1; } @@ -356,7 +356,7 @@ int MAIN(int argc, char **argv) if (st_bugs) SSL_CTX_set_options(tm_ctx, SSL_OP_ALL); - if(!SSL_CTX_set_cipher_list(tm_ctx, tm_cipher)) + if (!SSL_CTX_set_cipher_list(tm_ctx, tm_cipher)) goto end; if (!set_cert_stuff(tm_ctx, t_cert_file, t_key_file)) goto end; @@ -406,7 +406,7 @@ int MAIN(int argc, char **argv) if (s_www_path != NULL) { BIO_snprintf(buf, sizeof buf, "GET %s HTTP/1.0\r\n\r\n", s_www_path); - if(SSL_write(scon, buf, strlen(buf)) <= 0) + if (SSL_write(scon, buf, strlen(buf)) <= 0) goto end; while ((i = SSL_read(scon, buf, sizeof(buf))) > 0) bytes_read += i; @@ -463,7 +463,7 @@ int MAIN(int argc, char **argv) if (s_www_path != NULL) { BIO_snprintf(buf, sizeof buf, "GET %s HTTP/1.0\r\n\r\n", s_www_path); - if(SSL_write(scon, buf, strlen(buf)) <= 0) + if (SSL_write(scon, buf, strlen(buf)) <= 0) goto end; while (SSL_read(scon, buf, sizeof(buf)) > 0) ; } @@ -501,7 +501,7 @@ int MAIN(int argc, char **argv) if (s_www_path) { BIO_snprintf(buf, sizeof buf, "GET %s HTTP/1.0\r\n\r\n", s_www_path); - if(SSL_write(scon, buf, strlen(buf)) <= 0) + if (SSL_write(scon, buf, strlen(buf)) <= 0) goto end; while ((i = SSL_read(scon, buf, sizeof(buf))) > 0) bytes_read += i; diff --git a/apps/sess_id.c b/apps/sess_id.c index 53ccbb3576..9421e40842 100644 --- a/apps/sess_id.c +++ b/apps/sess_id.c @@ -166,7 +166,7 @@ int MAIN(int argc, char **argv) BIO_printf(bio_err, "Context too long\n"); goto end; } - if(!SSL_SESSION_set1_id_context(x, (unsigned char *)context, ctx_len)) { + if (!SSL_SESSION_set1_id_context(x, (unsigned char *)context, ctx_len)) { BIO_printf(bio_err, "Error setting id context\n"); goto end; } diff --git a/apps/speed.c b/apps/speed.c index df972a3b90..71aa74a446 100644 --- a/apps/speed.c +++ b/apps/speed.c @@ -2723,7 +2723,7 @@ static void multiblock_speed(const EVP_CIPHER *evp_cipher) inp = OPENSSL_malloc(mblengths[num - 1]); out = OPENSSL_malloc(mblengths[num - 1] + 1024); - if(!inp || !out) { + if (!inp || !out) { BIO_printf(bio_err,"Out of memory\n"); goto end; } @@ -2813,8 +2813,8 @@ static void multiblock_speed(const EVP_CIPHER *evp_cipher) } end: - if(inp) + if (inp) OPENSSL_free(inp); - if(out) + if (out) OPENSSL_free(out); } diff --git a/apps/srp.c b/apps/srp.c index b9312f8dfc..5acc7835d1 100644 --- a/apps/srp.c +++ b/apps/srp.c @@ -437,7 +437,7 @@ int MAIN(int argc, char **argv) # ifdef OPENSSL_SYS_VMS len = strlen(s) + sizeof(CONFIG_FILE); tofree = OPENSSL_malloc(len); - if(!tofree) { + if (!tofree) { BIO_printf(bio_err, "Out of memory\n"); goto err; } @@ -445,7 +445,7 @@ int MAIN(int argc, char **argv) # else len = strlen(s) + sizeof(CONFIG_FILE) + 1; tofree = OPENSSL_malloc(len); - if(!tofree) { + if (!tofree) { BIO_printf(bio_err, "Out of memory\n"); goto err; } diff --git a/crypto/asn1/bio_ndef.c b/crypto/asn1/bio_ndef.c index 1018787a63..99ab5f66e1 100644 --- a/crypto/asn1/bio_ndef.c +++ b/crypto/asn1/bio_ndef.c @@ -161,7 +161,7 @@ static int ndef_prefix(BIO *b, unsigned char **pbuf, int *plen, void *parg) derlen = ASN1_item_ndef_i2d(ndef_aux->val, NULL, ndef_aux->it); p = OPENSSL_malloc(derlen); - if(!p) + if (!p) return 0; ndef_aux->derbuf = p; @@ -231,7 +231,7 @@ static int ndef_suffix(BIO *b, unsigned char **pbuf, int *plen, void *parg) derlen = ASN1_item_ndef_i2d(ndef_aux->val, NULL, ndef_aux->it); p = OPENSSL_malloc(derlen); - if(!p) + if (!p) return 0; ndef_aux->derbuf = p; diff --git a/crypto/asn1/tasn_prn.c b/crypto/asn1/tasn_prn.c index d1e5ba509a..76d584b2ba 100644 --- a/crypto/asn1/tasn_prn.c +++ b/crypto/asn1/tasn_prn.c @@ -287,7 +287,7 @@ static int asn1_item_print_ctx(BIO *out, ASN1_VALUE **fld, int indent, for (i = 0, tt = it->templates; i < it->tcount; i++, tt++) { const ASN1_TEMPLATE *seqtt; seqtt = asn1_do_adb(fld, tt, 1); - if(!seqtt) + if (!seqtt) return 0; tmpfld = asn1_get_field_ptr(fld, seqtt); if (!asn1_template_print_ctx(out, tmpfld, diff --git a/crypto/asn1/x_x509.c b/crypto/asn1/x_x509.c index 36f6ff4362..08bb4bd33c 100644 --- a/crypto/asn1/x_x509.c +++ b/crypto/asn1/x_x509.c @@ -173,7 +173,7 @@ X509 *d2i_X509_AUX(X509 **a, const unsigned char **pp, long length) /* Save start position */ q = *pp; - if(!a || *a == NULL) { + if (!a || *a == NULL) { freeret = 1; } ret = d2i_X509(a, pp, length); @@ -188,7 +188,7 @@ X509 *d2i_X509_AUX(X509 **a, const unsigned char **pp, long length) goto err; return ret; err: - if(freeret) { + if (freeret) { X509_free(ret); if (a) *a = NULL; diff --git a/crypto/bio/b_print.c b/crypto/bio/b_print.c index c2cf6e619e..452e5cfd95 100644 --- a/crypto/bio/b_print.c +++ b/crypto/bio/b_print.c @@ -710,7 +710,7 @@ doapr_outch(char **sbuffer, if (*maxlen == 0) *maxlen = 1024; *buffer = OPENSSL_malloc(*maxlen); - if(!*buffer) { + if (!*buffer) { /* Panic! Can't really do anything sensible. Just return */ return; } @@ -722,7 +722,7 @@ doapr_outch(char **sbuffer, } else { *maxlen += 1024; *buffer = OPENSSL_realloc(*buffer, *maxlen); - if(!*buffer) { + if (!*buffer) { /* Panic! Can't really do anything sensible. Just return */ return; } diff --git a/crypto/bio/bss_dgram.c b/crypto/bio/bss_dgram.c index ed275d1cb1..4fa6279d05 100644 --- a/crypto/bio/bss_dgram.c +++ b/crypto/bio/bss_dgram.c @@ -998,7 +998,7 @@ BIO *BIO_new_dgram_sctp(int fd, int close_flag) */ sockopt_len = (socklen_t) (sizeof(sctp_assoc_t) + 256 * sizeof(uint8_t)); authchunks = OPENSSL_malloc(sockopt_len); - if(!authchunks) { + if (!authchunks) { BIO_vfree(bio); return (NULL); } @@ -1409,7 +1409,7 @@ static int dgram_sctp_write(BIO *b, const char *in, int inl) if (data->save_shutdown && !BIO_dgram_sctp_wait_for_dry(b)) { char *tmp; data->saved_message.bio = b; - if(!(tmp = OPENSSL_malloc(inl))) { + if (!(tmp = OPENSSL_malloc(inl))) { BIOerr(BIO_F_DGRAM_SCTP_WRITE, ERR_R_MALLOC_FAILURE); return -1; } diff --git a/crypto/cms/cms_pwri.c b/crypto/cms/cms_pwri.c index 4f1b31d8ae..e11b1fa4ac 100644 --- a/crypto/cms/cms_pwri.c +++ b/crypto/cms/cms_pwri.c @@ -231,7 +231,7 @@ static int kek_unwrap_key(unsigned char *out, size_t *outlen, return 0; } tmp = OPENSSL_malloc(inlen); - if(!tmp) + if (!tmp) return 0; /* setup IV by decrypting last two blocks */ if (!EVP_DecryptUpdate(ctx, tmp + inlen - 2 * blocklen, &outl, diff --git a/crypto/dh/dh_ameth.c b/crypto/dh/dh_ameth.c index cfa2e2dbec..4b22ec47b9 100644 --- a/crypto/dh/dh_ameth.c +++ b/crypto/dh/dh_ameth.c @@ -159,7 +159,7 @@ static int dh_pub_encode(X509_PUBKEY *pk, const EVP_PKEY *pkey) dh = pkey->pkey.dh; str = ASN1_STRING_new(); - if(!str) { + if (!str) { DHerr(DH_F_DH_PUB_ENCODE, ERR_R_MALLOC_FAILURE); goto err; } diff --git a/crypto/dh/dh_pmeth.c b/crypto/dh/dh_pmeth.c index 5e3a5e3fef..3fad0548a1 100644 --- a/crypto/dh/dh_pmeth.c +++ b/crypto/dh/dh_pmeth.c @@ -466,7 +466,7 @@ static int pkey_dh_derive(EVP_PKEY_CTX *ctx, unsigned char *key, ret = 0; Zlen = DH_size(dh); Z = OPENSSL_malloc(Zlen); - if(!Z) { + if (!Z) { goto err; } if (DH_compute_key_padded(Z, dhpub, dh) <= 0) diff --git a/crypto/dsa/dsa_ossl.c b/crypto/dsa/dsa_ossl.c index 96f5d6fed1..325eac479b 100644 --- a/crypto/dsa/dsa_ossl.c +++ b/crypto/dsa/dsa_ossl.c @@ -108,23 +108,23 @@ static DSA_METHOD openssl_dsa_meth = { #define DSA_MOD_EXP(err_instr,dsa,rr,a1,p1,a2,p2,m,ctx,in_mont) \ do { \ int _tmp_res53; \ - if((dsa)->meth->dsa_mod_exp) \ + if ((dsa)->meth->dsa_mod_exp) \ _tmp_res53 = (dsa)->meth->dsa_mod_exp((dsa), (rr), (a1), (p1), \ (a2), (p2), (m), (ctx), (in_mont)); \ else \ _tmp_res53 = BN_mod_exp2_mont((rr), (a1), (p1), (a2), (p2), \ (m), (ctx), (in_mont)); \ - if(!_tmp_res53) err_instr; \ + if (!_tmp_res53) err_instr; \ } while(0) #define DSA_BN_MOD_EXP(err_instr,dsa,r,a,p,m,ctx,m_ctx) \ do { \ int _tmp_res53; \ - if((dsa)->meth->bn_mod_exp) \ + if ((dsa)->meth->bn_mod_exp) \ _tmp_res53 = (dsa)->meth->bn_mod_exp((dsa), (r), (a), (p), \ (m), (ctx), (m_ctx)); \ else \ _tmp_res53 = BN_mod_exp_mont((r), (a), (p), (m), (ctx), (m_ctx)); \ - if(!_tmp_res53) err_instr; \ + if (!_tmp_res53) err_instr; \ } while(0) const DSA_METHOD *DSA_OpenSSL(void) diff --git a/crypto/dso/dso_lib.c b/crypto/dso/dso_lib.c index d2a48bb664..09b8eafcca 100644 --- a/crypto/dso/dso_lib.c +++ b/crypto/dso/dso_lib.c @@ -285,7 +285,7 @@ DSO_FUNC_TYPE DSO_bind_func(DSO *dso, const char *symname) * honest. For one thing, I think I have to return a negative value for any * error because possible DSO_ctrl() commands may return values such as * "size"s that can legitimately be zero (making the standard - * "if(DSO_cmd(...))" form that works almost everywhere else fail at odd + * "if (DSO_cmd(...))" form that works almost everywhere else fail at odd * times. I'd prefer "output" values to be passed by reference and the return * value as success/failure like usual ... but we conform when we must... :-) */ diff --git a/crypto/dso/dso_vms.c b/crypto/dso/dso_vms.c index d3c4eab269..79bbd97122 100644 --- a/crypto/dso/dso_vms.c +++ b/crypto/dso/dso_vms.c @@ -527,7 +527,7 @@ static char *vms_name_converter(DSO *dso, const char *filename) { int len = strlen(filename); char *not_translated = OPENSSL_malloc(len + 1); - if(not_translated) + if (not_translated) strcpy(not_translated, filename); return (not_translated); } diff --git a/crypto/hmac/hmac.c b/crypto/hmac/hmac.c index 8ee5b2ac19..ccfd16e08d 100644 --- a/crypto/hmac/hmac.c +++ b/crypto/hmac/hmac.c @@ -71,13 +71,13 @@ int HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int len, if (md != NULL) { reset = 1; ctx->md = md; - } else if(ctx->md) { + } else if (ctx->md) { md = ctx->md; } else { return 0; } - if(!ctx->key_init && key == NULL) + if (!ctx->key_init && key == NULL) return 0; if (key != NULL) { @@ -93,7 +93,7 @@ int HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int len, &ctx->key_length)) goto err; } else { - if(len < 0 || len > (int)sizeof(ctx->key)) + if (len < 0 || len > (int)sizeof(ctx->key)) return 0; memcpy(ctx->key, key, len); ctx->key_length = len; @@ -137,7 +137,7 @@ int HMAC_Init(HMAC_CTX *ctx, const void *key, int len, const EVP_MD *md) int HMAC_Update(HMAC_CTX *ctx, const unsigned char *data, size_t len) { - if(!ctx->key_init) + if (!ctx->key_init) return 0; return EVP_DigestUpdate(&ctx->md_ctx, data, len); } @@ -147,7 +147,7 @@ int HMAC_Final(HMAC_CTX *ctx, unsigned char *md, unsigned int *len) unsigned int i; unsigned char buf[EVP_MAX_MD_SIZE]; - if(!ctx->key_init) + if (!ctx->key_init) goto err; if (!EVP_DigestFinal_ex(&ctx->md_ctx, buf, &i)) @@ -182,7 +182,7 @@ int HMAC_CTX_copy(HMAC_CTX *dctx, HMAC_CTX *sctx) if (!EVP_MD_CTX_copy_ex(&dctx->md_ctx, &sctx->md_ctx)) goto err; dctx->key_init = sctx->key_init; - if(sctx->key_init) { + if (sctx->key_init) { memcpy(dctx->key, sctx->key, HMAC_MAX_MD_CBLOCK); dctx->key_length = sctx->key_length; } diff --git a/crypto/objects/o_names.c b/crypto/objects/o_names.c index 48ab1a7779..fa8709fa83 100644 --- a/crypto/objects/o_names.c +++ b/crypto/objects/o_names.c @@ -312,7 +312,7 @@ void OBJ_NAME_do_all_sorted(int type, d.names = OPENSSL_malloc(lh_OBJ_NAME_num_items(names_lh) * sizeof *d.names); /* Really should return an error if !d.names...but its a void function! */ - if(d.names) { + if (d.names) { d.n = 0; OBJ_NAME_do_all(type, do_all_sorted_fn, &d); diff --git a/crypto/rand/rand_os2.c b/crypto/rand/rand_os2.c index 02148d5bf9..706ab1e817 100644 --- a/crypto/rand/rand_os2.c +++ b/crypto/rand/rand_os2.c @@ -149,7 +149,7 @@ int RAND_poll(void) if (DosQuerySysState) { char *buffer = OPENSSL_malloc(256 * 1024); - if(!buffer) + if (!buffer) return 0; if (DosQuerySysState(0x1F, 0, 0, 0, buffer, 256 * 1024) == 0) { diff --git a/crypto/threads/th-lock.c b/crypto/threads/th-lock.c index 7b303b281a..6732dd76ed 100644 --- a/crypto/threads/th-lock.c +++ b/crypto/threads/th-lock.c @@ -117,7 +117,7 @@ void CRYPTO_thread_setup(void) int i; lock_cs = OPENSSL_malloc(CRYPTO_num_locks() * sizeof(HANDLE)); - if(!lock_cs) { + if (!lock_cs) { /* Nothing we can do about this...void function! */ return; } @@ -172,7 +172,7 @@ void CRYPTO_thread_setup(void) # else lock_cs = OPENSSL_malloc(CRYPTO_num_locks() * sizeof(rwlock_t)); # endif - if(!lock_cs) { + if (!lock_cs) { /* Nothing we can do about this...void function! */ return; } @@ -248,7 +248,7 @@ void CRYPTO_thread_setup(void) char filename[20]; lock_cs = OPENSSL_malloc(CRYPTO_num_locks() * sizeof(usema_t *)); - if(!lock_cs) { + if (!lock_cs) { /* Nothing we can do about this...void function! */ return; } @@ -316,11 +316,11 @@ void CRYPTO_thread_setup(void) lock_cs = OPENSSL_malloc(CRYPTO_num_locks() * sizeof(pthread_mutex_t)); lock_count = OPENSSL_malloc(CRYPTO_num_locks() * sizeof(long)); - if(!lock_cs || !lock_count) { + if (!lock_cs || !lock_count) { /* Nothing we can do about this...void function! */ - if(lock_cs) + if (lock_cs) OPENSSL_free(lock_cs); - if(lock_count) + if (lock_count) OPENSSL_free(lock_count); return; } diff --git a/crypto/x509v3/v3_cpols.c b/crypto/x509v3/v3_cpols.c index 66d486f97f..8147ea598e 100644 --- a/crypto/x509v3/v3_cpols.c +++ b/crypto/x509v3/v3_cpols.c @@ -230,11 +230,11 @@ static POLICYINFO *policy_section(X509V3_CTX *ctx, goto merr; if (!sk_POLICYQUALINFO_push(pol->qualifiers, qual)) goto merr; - if(!(qual->pqualid = OBJ_nid2obj(NID_id_qt_cps))) { + if (!(qual->pqualid = OBJ_nid2obj(NID_id_qt_cps))) { X509V3err(X509V3_F_POLICY_SECTION, ERR_R_INTERNAL_ERROR); goto err; } - if(!(qual->d.cpsuri = ASN1_IA5STRING_new())) + if (!(qual->d.cpsuri = ASN1_IA5STRING_new())) goto merr; if (!ASN1_STRING_set(qual->d.cpsuri, cnf->value, strlen(cnf->value))) @@ -294,7 +294,7 @@ static POLICYQUALINFO *notice_section(X509V3_CTX *ctx, POLICYQUALINFO *qual; if (!(qual = POLICYQUALINFO_new())) goto merr; - if(!(qual->pqualid = OBJ_nid2obj(NID_id_qt_unotice))) { + if (!(qual->pqualid = OBJ_nid2obj(NID_id_qt_unotice))) { X509V3err(X509V3_F_NOTICE_SECTION, ERR_R_INTERNAL_ERROR); goto err; } @@ -304,7 +304,7 @@ static POLICYQUALINFO *notice_section(X509V3_CTX *ctx, for (i = 0; i < sk_CONF_VALUE_num(unot); i++) { cnf = sk_CONF_VALUE_value(unot, i); if (!strcmp(cnf->name, "explicitText")) { - if(!(not->exptext = ASN1_VISIBLESTRING_new())) + if (!(not->exptext = ASN1_VISIBLESTRING_new())) goto merr; if (!ASN1_STRING_set(not->exptext, cnf->value, strlen(cnf->value))) diff --git a/engines/ccgost/gost2001.c b/engines/ccgost/gost2001.c index 5c4efd6e57..83cc693f75 100644 --- a/engines/ccgost/gost2001.c +++ b/engines/ccgost/gost2001.c @@ -41,7 +41,7 @@ int fill_GOST2001_params(EC_KEY *eckey, int nid) BN_CTX *ctx = BN_CTX_new(); int ok = 0; - if(!ctx) { + if (!ctx) { GOSTerr(GOST_F_FILL_GOST2001_PARAMS, ERR_R_MALLOC_FAILURE); goto err; } @@ -53,7 +53,7 @@ int fill_GOST2001_params(EC_KEY *eckey, int nid) x = BN_CTX_get(ctx); y = BN_CTX_get(ctx); q = BN_CTX_get(ctx); - if(!p || !a || !b || !x || !y || !q) { + if (!p || !a || !b || !x || !y || !q) { GOSTerr(GOST_F_FILL_GOST2001_PARAMS, ERR_R_MALLOC_FAILURE); goto err; } @@ -64,7 +64,7 @@ int fill_GOST2001_params(EC_KEY *eckey, int nid) GOST_R_UNSUPPORTED_PARAMETER_SET); goto err; } - if(!BN_hex2bn(&p, params->p) + if (!BN_hex2bn(&p, params->p) || !BN_hex2bn(&a, params->a) || !BN_hex2bn(&b, params->b)) { GOSTerr(GOST_F_FILL_GOST2001_PARAMS, @@ -73,18 +73,18 @@ int fill_GOST2001_params(EC_KEY *eckey, int nid) } grp = EC_GROUP_new_curve_GFp(p, a, b, ctx); - if(!grp) { + if (!grp) { GOSTerr(GOST_F_FILL_GOST2001_PARAMS, ERR_R_MALLOC_FAILURE); goto err; } P = EC_POINT_new(grp); - if(!P) { + if (!P) { GOSTerr(GOST_F_FILL_GOST2001_PARAMS, ERR_R_MALLOC_FAILURE); goto err; } - if(!BN_hex2bn(&x, params->x) + if (!BN_hex2bn(&x, params->x) || !BN_hex2bn(&y, params->y) || !EC_POINT_set_affine_coordinates_GFp(grp, P, x, y, ctx) || !BN_hex2bn(&q, params->q)) { @@ -98,12 +98,12 @@ int fill_GOST2001_params(EC_KEY *eckey, int nid) fprintf(stderr, "\n"); #endif - if(!EC_GROUP_set_generator(grp, P, q, NULL)) { + if (!EC_GROUP_set_generator(grp, P, q, NULL)) { GOSTerr(GOST_F_FILL_GOST2001_PARAMS, ERR_R_INTERNAL_ERROR); goto err; } EC_GROUP_set_curve_name(grp, params->nid); - if(!EC_KEY_set_group(eckey, grp)) { + if (!EC_KEY_set_group(eckey, grp)) { GOSTerr(GOST_F_FILL_GOST2001_PARAMS, ERR_R_INTERNAL_ERROR); goto err; } @@ -134,7 +134,7 @@ DSA_SIG *gost2001_do_sign(const unsigned char *dgst, int dlen, EC_KEY *eckey) NULL, *e = NULL; EC_POINT *C = NULL; BN_CTX *ctx = BN_CTX_new(); - if(!ctx || !md) { + if (!ctx || !md) { GOSTerr(GOST_F_GOST2001_DO_SIGN, ERR_R_MALLOC_FAILURE); goto err; } @@ -146,22 +146,22 @@ DSA_SIG *gost2001_do_sign(const unsigned char *dgst, int dlen, EC_KEY *eckey) goto err; } group = EC_KEY_get0_group(eckey); - if(!group) { + if (!group) { GOSTerr(GOST_F_GOST2001_DO_SIGN, ERR_R_INTERNAL_ERROR); goto err; } order = BN_CTX_get(ctx); - if(!order || !EC_GROUP_get_order(group, order, ctx)) { + if (!order || !EC_GROUP_get_order(group, order, ctx)) { GOSTerr(GOST_F_GOST2001_DO_SIGN, ERR_R_INTERNAL_ERROR); goto err; } priv_key = EC_KEY_get0_private_key(eckey); - if(!priv_key) { + if (!priv_key) { GOSTerr(GOST_F_GOST2001_DO_SIGN, ERR_R_INTERNAL_ERROR); goto err; } e = BN_CTX_get(ctx); - if(!e || !BN_mod(e, md, order, ctx)) { + if (!e || !BN_mod(e, md, order, ctx)) { GOSTerr(GOST_F_GOST2001_DO_SIGN, ERR_R_INTERNAL_ERROR); goto err; } @@ -177,7 +177,7 @@ DSA_SIG *gost2001_do_sign(const unsigned char *dgst, int dlen, EC_KEY *eckey) } k = BN_CTX_get(ctx); C = EC_POINT_new(group); - if(!k || !C) { + if (!k || !C) { GOSTerr(GOST_F_GOST2001_DO_SIGN, ERR_R_MALLOC_FAILURE); goto err; } @@ -205,7 +205,7 @@ DSA_SIG *gost2001_do_sign(const unsigned char *dgst, int dlen, EC_KEY *eckey) goto err; } - if(!BN_nnmod(r, X, order, ctx)) { + if (!BN_nnmod(r, X, order, ctx)) { GOSTerr(GOST_F_GOST2001_DO_SIGN, ERR_R_INTERNAL_ERROR); goto err; } @@ -223,7 +223,7 @@ DSA_SIG *gost2001_do_sign(const unsigned char *dgst, int dlen, EC_KEY *eckey) goto err; } - if(!BN_mod_mul(tmp, priv_key, r, order, ctx) + if (!BN_mod_mul(tmp, priv_key, r, order, ctx) || !BN_mod_mul(tmp2, k, e, order, ctx) || !BN_mod_add(s, tmp, tmp2, order, ctx)) { GOSTerr(GOST_F_GOST2001_DO_SIGN, ERR_R_INTERNAL_ERROR); @@ -234,14 +234,14 @@ DSA_SIG *gost2001_do_sign(const unsigned char *dgst, int dlen, EC_KEY *eckey) newsig->s = BN_dup(s); newsig->r = BN_dup(r); - if(!newsig->s || !newsig->r) { + if (!newsig->s || !newsig->r) { GOSTerr(GOST_F_GOST2001_DO_SIGN, ERR_R_MALLOC_FAILURE); goto err; } ret = newsig; err: - if(ctx) { + if (ctx) { BN_CTX_end(ctx); BN_CTX_free(ctx); } @@ -270,7 +270,7 @@ int gost2001_do_verify(const unsigned char *dgst, int dgst_len, const EC_POINT *pub_key = NULL; int ok = 0; - if(!ctx || !group) { + if (!ctx || !group) { GOSTerr(GOST_F_GOST2001_DO_VERIFY, ERR_R_INTERNAL_ERROR); goto err; } @@ -284,13 +284,13 @@ int gost2001_do_verify(const unsigned char *dgst, int dgst_len, X = BN_CTX_get(ctx); R = BN_CTX_get(ctx); v = BN_CTX_get(ctx); - if(!order || !e || !z1 || !z2 || !tmp || !X || !R || !v) { + if (!order || !e || !z1 || !z2 || !tmp || !X || !R || !v) { GOSTerr(GOST_F_GOST2001_DO_VERIFY, ERR_R_MALLOC_FAILURE); goto err; } pub_key = EC_KEY_get0_public_key(ec); - if(!pub_key || !EC_GROUP_get_order(group, order, ctx)) { + if (!pub_key || !EC_GROUP_get_order(group, order, ctx)) { GOSTerr(GOST_F_GOST2001_DO_VERIFY, ERR_R_INTERNAL_ERROR); goto err; } @@ -304,7 +304,7 @@ int gost2001_do_verify(const unsigned char *dgst, int dgst_len, } md = hashsum2bn(dgst); - if(!md || !BN_mod(e, md, order, ctx)) { + if (!md || !BN_mod(e, md, order, ctx)) { GOSTerr(GOST_F_GOST2001_DO_VERIFY, ERR_R_INTERNAL_ERROR); goto err; } @@ -319,7 +319,7 @@ int gost2001_do_verify(const unsigned char *dgst, int dgst_len, goto err; } v = BN_mod_inverse(v, e, order, ctx); - if(!v + if (!v || !BN_mod_mul(z1, sig->s, v, order, ctx) || !BN_sub(tmp, order, sig->r) || !BN_mod_mul(z2, tmp, v, order, ctx)) { @@ -347,7 +347,7 @@ int gost2001_do_verify(const unsigned char *dgst, int dgst_len, GOSTerr(GOST_F_GOST2001_DO_VERIFY, ERR_R_EC_LIB); goto err; } - if(!BN_mod(R, X, order, ctx)) { + if (!BN_mod(R, X, order, ctx)) { GOSTerr(GOST_F_GOST2001_DO_VERIFY, ERR_R_INTERNAL_ERROR); goto err; } @@ -392,7 +392,7 @@ int gost2001_compute_public(EC_KEY *ec) return 0; } ctx = BN_CTX_new(); - if(!ctx) { + if (!ctx) { GOSTerr(GOST_F_GOST2001_COMPUTE_PUBLIC, ERR_R_MALLOC_FAILURE); goto err; } @@ -403,7 +403,7 @@ int gost2001_compute_public(EC_KEY *ec) } pub_key = EC_POINT_new(group); - if(!pub_key) { + if (!pub_key) { GOSTerr(GOST_F_GOST2001_COMPUTE_PUBLIC, ERR_R_MALLOC_FAILURE); goto err; } @@ -436,7 +436,7 @@ int gost2001_keygen(EC_KEY *ec) BIGNUM *order = BN_new(), *d = BN_new(); const EC_GROUP *group = EC_KEY_get0_group(ec); - if(!group || !EC_GROUP_get_order(group, order, NULL)) { + if (!group || !EC_GROUP_get_order(group, order, NULL)) { GOSTerr(GOST_F_GOST2001_KEYGEN, ERR_R_INTERNAL_ERROR); BN_free(d); BN_free(order); @@ -454,7 +454,7 @@ int gost2001_keygen(EC_KEY *ec) } while (BN_is_zero(d)); - if(!EC_KEY_set_private_key(ec, d)) { + if (!EC_KEY_set_private_key(ec, d)) { GOSTerr(GOST_F_GOST2001_KEYGEN, ERR_R_INTERNAL_ERROR); BN_free(d); BN_free(order); diff --git a/engines/ccgost/gost_ameth.c b/engines/ccgost/gost_ameth.c index c5ca44f3f7..b1615bfa6c 100644 --- a/engines/ccgost/gost_ameth.c +++ b/engines/ccgost/gost_ameth.c @@ -115,7 +115,7 @@ static int decode_gost_algor_params(EVP_PKEY *pkey, X509_ALGOR *palg) } param_nid = OBJ_obj2nid(gkp->key_params); GOST_KEY_PARAMS_free(gkp); - if(!EVP_PKEY_set_type(pkey, pkey_nid)) { + if (!EVP_PKEY_set_type(pkey, pkey_nid)) { GOSTerr(GOST_F_DECODE_GOST_ALGOR_PARAMS, ERR_R_INTERNAL_ERROR); return 0; } @@ -549,16 +549,16 @@ static int param_copy_gost01(EVP_PKEY *to, const EVP_PKEY *from) } if (!eto) { eto = EC_KEY_new(); - if(!eto) { + if (!eto) { GOSTerr(GOST_F_PARAM_COPY_GOST01, ERR_R_MALLOC_FAILURE); return 0; } - if(!EVP_PKEY_assign(to, EVP_PKEY_base_id(from), eto)) { + if (!EVP_PKEY_assign(to, EVP_PKEY_base_id(from), eto)) { GOSTerr(GOST_F_PARAM_COPY_GOST01, ERR_R_INTERNAL_ERROR); return 0; } } - if(!EC_KEY_set_group(eto, EC_KEY_get0_group(efrom))) { + if (!EC_KEY_set_group(eto, EC_KEY_get0_group(efrom))) { GOSTerr(GOST_F_PARAM_COPY_GOST01, ERR_R_INTERNAL_ERROR); return 0; } @@ -756,14 +756,16 @@ static int pub_encode_gost01(X509_PUBKEY *pub, const EVP_PKEY *pk) } X = BN_new(); Y = BN_new(); - if(!X || !Y) { + if (!X || !Y) { GOSTerr(GOST_F_PUB_ENCODE_GOST01, ERR_R_MALLOC_FAILURE); - if(X) BN_free(X); - if(Y) BN_free(Y); + if (X) + BN_free(X); + if (Y) + BN_free(Y); BN_free(order); return 0; } - if(!EC_POINT_get_affine_coordinates_GFp(EC_KEY_get0_group(ec), + if (!EC_POINT_get_affine_coordinates_GFp(EC_KEY_get0_group(ec), pub_key, X, Y, NULL)) { GOSTerr(GOST_F_PUB_ENCODE_GOST01, ERR_R_INTERNAL_ERROR); BN_free(X); diff --git a/engines/ccgost/gost_sign.c b/engines/ccgost/gost_sign.c index 1d7ed86da2..c2516ead0e 100644 --- a/engines/ccgost/gost_sign.c +++ b/engines/ccgost/gost_sign.c @@ -58,7 +58,7 @@ DSA_SIG *gost_do_sign(const unsigned char *dgst, int dlen, DSA *dsa) BIGNUM *md = hashsum2bn(dgst); /* check if H(M) mod q is zero */ BN_CTX *ctx = BN_CTX_new(); - if(!ctx) { + if (!ctx) { GOSTerr(GOST_F_GOST_DO_SIGN, ERR_R_MALLOC_FAILURE); goto err; } @@ -71,7 +71,7 @@ DSA_SIG *gost_do_sign(const unsigned char *dgst, int dlen, DSA *dsa) tmp = BN_CTX_get(ctx); k = BN_CTX_get(ctx); tmp2 = BN_CTX_get(ctx); - if(!tmp || !k || !tmp2) { + if (!tmp || !k || !tmp2) { GOSTerr(GOST_F_GOST_DO_SIGN, ERR_R_MALLOC_FAILURE); goto err; } @@ -89,7 +89,7 @@ DSA_SIG *gost_do_sign(const unsigned char *dgst, int dlen, DSA *dsa) BN_mod_exp(tmp, dsa->g, k, dsa->p, ctx); if (!(newsig->r)) { newsig->r = BN_new(); - if(!newsig->r) { + if (!newsig->r) { GOSTerr(GOST_F_GOST_DO_SIGN, ERR_R_MALLOC_FAILURE); goto err; } @@ -102,7 +102,7 @@ DSA_SIG *gost_do_sign(const unsigned char *dgst, int dlen, DSA *dsa) BN_mod_mul(tmp2, k, md, dsa->q, ctx); if (!newsig->s) { newsig->s = BN_new(); - if(!newsig->s) { + if (!newsig->s) { GOSTerr(GOST_F_GOST_DO_SIGN, ERR_R_MALLOC_FAILURE); goto err; } @@ -114,11 +114,11 @@ DSA_SIG *gost_do_sign(const unsigned char *dgst, int dlen, DSA *dsa) ret = newsig; err: BN_free(md); - if(ctx) { + if (ctx) { BN_CTX_end(ctx); BN_CTX_free(ctx); } - if(!ret && newsig) { + if (!ret && newsig) { DSA_SIG_free(newsig); } return ret; @@ -169,7 +169,7 @@ int gost_do_verify(const unsigned char *dgst, int dgst_len, BIGNUM *tmp2 = NULL, *tmp3 = NULL; int ok = 0; BN_CTX *ctx = BN_CTX_new(); - if(!ctx) { + if (!ctx) { GOSTerr(GOST_F_GOST_DO_VERIFY, ERR_R_MALLOC_FAILURE); goto err; } @@ -189,7 +189,7 @@ int gost_do_verify(const unsigned char *dgst, int dgst_len, tmp2 = BN_CTX_get(ctx); tmp3 = BN_CTX_get(ctx); u = BN_CTX_get(ctx); - if(!tmp || !v || !q2 || !z1 || !z2 || !tmp2 || !tmp3 || !u) { + if (!tmp || !v || !q2 || !z1 || !z2 || !tmp2 || !tmp3 || !u) { GOSTerr(GOST_F_GOST_DO_VERIFY, ERR_R_MALLOC_FAILURE); goto err; } @@ -214,8 +214,9 @@ int gost_do_verify(const unsigned char *dgst, int dgst_len, GOSTerr(GOST_F_GOST_DO_VERIFY, GOST_R_SIGNATURE_MISMATCH); } err: - if(md) BN_free(md); - if(ctx) { + if (md) + BN_free(md); + if (ctx) { BN_CTX_end(ctx); BN_CTX_free(ctx); } @@ -235,13 +236,13 @@ int gost94_compute_public(DSA *dsa) return 0; } ctx = BN_CTX_new(); - if(!ctx) { + if (!ctx) { GOSTerr(GOST_F_GOST94_COMPUTE_PUBLIC, ERR_R_MALLOC_FAILURE); return 0; } dsa->pub_key = BN_new(); - if(!dsa->pub_key) { + if (!dsa->pub_key) { GOSTerr(GOST_F_GOST94_COMPUTE_PUBLIC, ERR_R_MALLOC_FAILURE); BN_CTX_free(ctx); return 0; @@ -293,7 +294,7 @@ int fill_GOST94_params(DSA *dsa, int nid) int gost_sign_keygen(DSA *dsa) { dsa->priv_key = BN_new(); - if(!dsa->priv_key) { + if (!dsa->priv_key) { GOSTerr(GOST_F_GOST_SIGN_KEYGEN, ERR_R_MALLOC_FAILURE); return 0; } diff --git a/engines/e_sureware.c b/engines/e_sureware.c index 5e1786ca0f..4580250d98 100644 --- a/engines/e_sureware.c +++ b/engines/e_sureware.c @@ -710,7 +710,7 @@ static EVP_PKEY *sureware_load_public(ENGINE *e, const char *key_id, /* set public big nums */ rsatmp->e = BN_new(); rsatmp->n = BN_new(); - if(!rsatmp->e || !rsatmp->n) + if (!rsatmp->e || !rsatmp->n) goto err; bn_expand2(rsatmp->e, el / sizeof(BN_ULONG)); bn_expand2(rsatmp->n, el / sizeof(BN_ULONG)); @@ -752,7 +752,7 @@ static EVP_PKEY *sureware_load_public(ENGINE *e, const char *key_id, dsatmp->p = BN_new(); dsatmp->q = BN_new(); dsatmp->g = BN_new(); - if(!dsatmp->pub_key || !dsatmp->p || !dsatmp->q || !dsatmp->g) + if (!dsatmp->pub_key || !dsatmp->p || !dsatmp->q || !dsatmp->g) goto err; bn_expand2(dsatmp->pub_key, el / sizeof(BN_ULONG)); bn_expand2(dsatmp->p, el / sizeof(BN_ULONG)); @@ -1018,7 +1018,7 @@ static DSA_SIG *surewarehk_dsa_do_sign(const unsigned char *from, int flen, } psign->r = BN_new(); psign->s = BN_new(); - if(!psign->r || !psign->s) + if (!psign->r || !psign->s) goto err; bn_expand2(psign->r, 20 / sizeof(BN_ULONG)); bn_expand2(psign->s, 20 / sizeof(BN_ULONG)); diff --git a/ssl/bio_ssl.c b/ssl/bio_ssl.c index 7cf941d15b..473b3ff519 100644 --- a/ssl/bio_ssl.c +++ b/ssl/bio_ssl.c @@ -292,7 +292,7 @@ static long ssl_ctrl(BIO *b, int cmd, long num, void *ptr) else if (ssl->handshake_func == ssl->method->ssl_accept) SSL_set_accept_state(ssl); - if(!SSL_clear(ssl)) { + if (!SSL_clear(ssl)) { ret = 0; break; } @@ -555,7 +555,7 @@ int BIO_ssl_copy_session_id(BIO *t, BIO *f) if ((((BIO_SSL *)t->ptr)->ssl == NULL) || (((BIO_SSL *)f->ptr)->ssl == NULL)) return (0); - if(!SSL_copy_session_id(((BIO_SSL *)t->ptr)->ssl, ((BIO_SSL *)f->ptr)->ssl)) + if (!SSL_copy_session_id(((BIO_SSL *)t->ptr)->ssl, ((BIO_SSL *)f->ptr)->ssl)) return 0; return (1); } diff --git a/ssl/d1_both.c b/ssl/d1_both.c index 094b337bea..c3552e9276 100644 --- a/ssl/d1_both.c +++ b/ssl/d1_both.c @@ -989,7 +989,7 @@ int dtls1_send_change_cipher_spec(SSL *s, int a, int b) s->d1->handshake_write_seq, 0, 0); /* buffer the message to handle re-xmits */ - if(!dtls1_buffer_message(s, 1)) { + if (!dtls1_buffer_message(s, 1)) { SSLerr(SSL_F_DTLS1_SEND_CHANGE_CIPHER_SPEC, ERR_R_INTERNAL_ERROR); return -1; } diff --git a/ssl/d1_clnt.c b/ssl/d1_clnt.c index c5831cd2eb..0f4373ee7e 100644 --- a/ssl/d1_clnt.c +++ b/ssl/d1_clnt.c @@ -182,7 +182,7 @@ int dtls1_connect(SSL *s) s->in_handshake++; if (!SSL_in_init(s) || SSL_in_before(s)) { - if(!SSL_clear(s)) + if (!SSL_clear(s)) return -1; } diff --git a/ssl/d1_lib.c b/ssl/d1_lib.c index eac271d27b..a1d203223c 100644 --- a/ssl/d1_lib.c +++ b/ssl/d1_lib.c @@ -124,7 +124,7 @@ int dtls1_new(SSL *s) { DTLS1_STATE *d1; - if(!DTLS_RECORD_LAYER_new(&s->rlayer)) { + if (!DTLS_RECORD_LAYER_new(&s->rlayer)) { return 0; } @@ -502,7 +502,7 @@ int dtls1_listen(SSL *s, struct sockaddr *client) int ret; /* Ensure there is no state left over from a previous invocation */ - if(!SSL_clear(s)) + if (!SSL_clear(s)) return -1; SSL_set_options(s, SSL_OP_COOKIE_EXCHANGE); @@ -524,7 +524,7 @@ static int dtls1_set_handshake_header(SSL *s, int htype, unsigned long len) s->init_off = 0; /* Buffer the message to handle re-xmits */ - if(!dtls1_buffer_message(s, 0)) + if (!dtls1_buffer_message(s, 0)) return 0; return 1; diff --git a/ssl/d1_srvr.c b/ssl/d1_srvr.c index 5ddfeac4c2..663f118103 100644 --- a/ssl/d1_srvr.c +++ b/ssl/d1_srvr.c @@ -185,7 +185,7 @@ int dtls1_accept(SSL *s) /* init things to blank */ s->in_handshake++; if (!SSL_in_init(s) || SSL_in_before(s)) { - if(!SSL_clear(s)) + if (!SSL_clear(s)) return -1; } diff --git a/ssl/record/rec_layer_d1.c b/ssl/record/rec_layer_d1.c index c58af7f36a..3183bcf79c 100644 --- a/ssl/record/rec_layer_d1.c +++ b/ssl/record/rec_layer_d1.c @@ -638,7 +638,7 @@ int dtls1_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek) #ifndef OPENSSL_NO_HEARTBEATS else if (SSL3_RECORD_get_type(rr) == TLS1_RT_HEARTBEAT) { /* We allow a 0 return */ - if(dtls1_process_heartbeat(s, SSL3_RECORD_get_data(rr), + if (dtls1_process_heartbeat(s, SSL3_RECORD_get_data(rr), SSL3_RECORD_get_length(rr)) < 0) { return -1; } diff --git a/ssl/record/rec_layer_s3.c b/ssl/record/rec_layer_s3.c index 0ec1d2ca4c..b7d43f3543 100644 --- a/ssl/record/rec_layer_s3.c +++ b/ssl/record/rec_layer_s3.c @@ -170,7 +170,7 @@ void RECORD_LAYER_clear(RECORD_LAYER *rl) rl->s = s; rl->d = d; - if(d) + if (d) DTLS_RECORD_LAYER_clear(rl); } @@ -196,7 +196,7 @@ int RECORD_LAYER_write_pending(RECORD_LAYER *rl) int RECORD_LAYER_set_data(RECORD_LAYER *rl, const unsigned char *buf, int len) { rl->packet_length = len; - if(len != 0) { + if (len != 0) { rl->rstate = SSL_ST_READ_HEADER; if (!SSL3_BUFFER_is_initialised(&rl->rbuf)) if (!ssl3_setup_read_buffer(rl->s)) @@ -531,7 +531,7 @@ int ssl3_write_bytes(SSL *s, int type, const void *buf_, int len) packlen *= 4; wb->buf = OPENSSL_malloc(packlen); - if(!wb->buf) { + if (!wb->buf) { SSLerr(SSL_F_SSL3_WRITE_BYTES, ERR_R_MALLOC_FAILURE); return -1; } @@ -1130,7 +1130,7 @@ int ssl3_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek) #ifndef OPENSSL_NO_HEARTBEATS else if (SSL3_RECORD_get_type(rr)== TLS1_RT_HEARTBEAT) { /* We can ignore 0 return values */ - if(tls1_process_heartbeat(s, SSL3_RECORD_get_data(rr), + if (tls1_process_heartbeat(s, SSL3_RECORD_get_data(rr), SSL3_RECORD_get_length(rr)) < 0) { return -1; } diff --git a/ssl/record/ssl3_buffer.c b/ssl/record/ssl3_buffer.c index 79a7636e07..732420e27b 100644 --- a/ssl/record/ssl3_buffer.c +++ b/ssl/record/ssl3_buffer.c @@ -114,7 +114,7 @@ void SSL3_BUFFER_set_data(SSL3_BUFFER *b, const unsigned char *d, int n) { - if(d != NULL) + if (d != NULL) memcpy(b->buf, d, n); b->left = n; b->offset = 0; diff --git a/ssl/s23_clnt.c b/ssl/s23_clnt.c index 76ad876ec4..4196eac2a9 100644 --- a/ssl/s23_clnt.c +++ b/ssl/s23_clnt.c @@ -158,7 +158,7 @@ int ssl23_connect(SSL *s) s->in_handshake++; if (!SSL_in_init(s) || SSL_in_before(s)) { - if(!SSL_clear(s)) + if (!SSL_clear(s)) return -1; } @@ -573,7 +573,7 @@ static int ssl23_get_server_hello(SSL *s) /* * put the 7 bytes we have read into the input buffer for SSLv3 */ - if(!RECORD_LAYER_set_data(&s->rlayer, buf, n)) + if (!RECORD_LAYER_set_data(&s->rlayer, buf, n)) goto err; s->handshake_func = s->method->ssl_connect; diff --git a/ssl/s23_srvr.c b/ssl/s23_srvr.c index 7287022d23..50d634e265 100644 --- a/ssl/s23_srvr.c +++ b/ssl/s23_srvr.c @@ -157,7 +157,7 @@ int ssl23_accept(SSL *s) s->in_handshake++; if (!SSL_in_init(s) || SSL_in_before(s)) { - if(!SSL_clear(s)) + if (!SSL_clear(s)) return -1; } @@ -561,10 +561,10 @@ int ssl23_get_client_hello(SSL *s) /* * put the 'n' bytes we have read into the input buffer for SSLv3 */ - if(!RECORD_LAYER_set_data(&s->rlayer, buf, n)) + if (!RECORD_LAYER_set_data(&s->rlayer, buf, n)) goto err; } else { - if(!RECORD_LAYER_set_data(&s->rlayer, NULL, 0)) + if (!RECORD_LAYER_set_data(&s->rlayer, NULL, 0)) goto err; } s->handshake_func = s->method->ssl_accept; diff --git a/ssl/s3_both.c b/ssl/s3_both.c index ed6ae128d5..d0cb763b8d 100644 --- a/ssl/s3_both.c +++ b/ssl/s3_both.c @@ -187,7 +187,7 @@ int ssl3_send_finished(SSL *s, int a, int b, const char *sender, int slen) s->s3->previous_server_finished_len = i; } - if(!ssl_set_handshake_header(s, SSL3_MT_FINISHED, l)) { + if (!ssl_set_handshake_header(s, SSL3_MT_FINISHED, l)) { SSLerr(SSL_F_SSL3_SEND_FINISHED, ERR_R_INTERNAL_ERROR); return -1; } @@ -328,7 +328,7 @@ unsigned long ssl3_output_cert_chain(SSL *s, CERT_PKEY *cpk) l2n3(l, p); l += 3; - if(!ssl_set_handshake_header(s, SSL3_MT_CERTIFICATE, l)) { + if (!ssl_set_handshake_header(s, SSL3_MT_CERTIFICATE, l)) { SSLerr(SSL_F_SSL3_OUTPUT_CERT_CHAIN, ERR_R_INTERNAL_ERROR); return 0; } diff --git a/ssl/s3_clnt.c b/ssl/s3_clnt.c index 404f7f9f8f..697a3b4f6a 100644 --- a/ssl/s3_clnt.c +++ b/ssl/s3_clnt.c @@ -198,7 +198,7 @@ int ssl3_connect(SSL *s) s->in_handshake++; if (!SSL_in_init(s) || SSL_in_before(s)) { - if(!SSL_clear(s)) + if (!SSL_clear(s)) return -1; } @@ -843,7 +843,7 @@ int ssl3_client_hello(SSL *s) #endif l = p - d; - if(!ssl_set_handshake_header(s, SSL3_MT_CLIENT_HELLO, l)) { + if (!ssl_set_handshake_header(s, SSL3_MT_CLIENT_HELLO, l)) { ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_HANDSHAKE_FAILURE); SSLerr(SSL_F_SSL3_CLIENT_HELLO, ERR_R_INTERNAL_ERROR); goto err; @@ -2991,7 +2991,7 @@ int ssl3_send_client_key_exchange(SSL *s) goto err; } - if(!ssl_set_handshake_header(s, SSL3_MT_CLIENT_KEY_EXCHANGE, n)) { + if (!ssl_set_handshake_header(s, SSL3_MT_CLIENT_KEY_EXCHANGE, n)) { ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_HANDSHAKE_FAILURE); SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR); goto err; @@ -3044,7 +3044,7 @@ int ssl3_send_client_key_exchange(SSL *s) OPENSSL_cleanse(pms, pmslen); OPENSSL_free(pms); s->cert->pms = NULL; - if(s->session->master_key_length < 0) { + if (s->session->master_key_length < 0) { ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_INTERNAL_ERROR); SSLerr(SSL_F_SSL3_SEND_CLIENT_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR); goto err; @@ -3194,7 +3194,7 @@ int ssl3_send_client_verify(SSL *s) SSLerr(SSL_F_SSL3_SEND_CLIENT_VERIFY, ERR_R_INTERNAL_ERROR); goto err; } - if(!ssl_set_handshake_header(s, SSL3_MT_CERTIFICATE_VERIFY, n)) { + if (!ssl_set_handshake_header(s, SSL3_MT_CERTIFICATE_VERIFY, n)) { SSLerr(SSL_F_SSL3_SEND_CLIENT_VERIFY, ERR_R_INTERNAL_ERROR); goto err; } diff --git a/ssl/s3_enc.c b/ssl/s3_enc.c index 1db2f77cd4..8fc5bc4a8a 100644 --- a/ssl/s3_enc.c +++ b/ssl/s3_enc.c @@ -253,7 +253,7 @@ int ssl3_change_cipher_state(SSL *s, int which) EVP_CIPHER_CTX_init(s->enc_read_ctx); dd = s->enc_read_ctx; - if(!ssl_replace_hash(&s->read_hash, m)) { + if (!ssl_replace_hash(&s->read_hash, m)) { SSLerr(SSL_F_SSL3_CHANGE_CIPHER_STATE, ERR_R_INTERNAL_ERROR); goto err2; } @@ -270,7 +270,7 @@ int ssl3_change_cipher_state(SSL *s, int which) SSL_R_COMPRESSION_LIBRARY_ERROR); goto err2; } - if(!RECORD_LAYER_setup_comp_buffer(&s->rlayer)) + if (!RECORD_LAYER_setup_comp_buffer(&s->rlayer)) goto err; } #endif @@ -288,7 +288,7 @@ int ssl3_change_cipher_state(SSL *s, int which) */ EVP_CIPHER_CTX_init(s->enc_write_ctx); dd = s->enc_write_ctx; - if(!ssl_replace_hash(&s->write_hash, m)) { + if (!ssl_replace_hash(&s->write_hash, m)) { SSLerr(SSL_F_SSL3_CHANGE_CIPHER_STATE, ERR_R_INTERNAL_ERROR); goto err2; } diff --git a/ssl/s3_lib.c b/ssl/s3_lib.c index a7dbbf688d..7bb3a9257f 100644 --- a/ssl/s3_lib.c +++ b/ssl/s3_lib.c @@ -3104,7 +3104,7 @@ int ssl3_new(SSL *s) s->s3 = s3; #ifndef OPENSSL_NO_SRP - if(!SSL_SRP_CTX_init(s)) + if (!SSL_SRP_CTX_init(s)) goto err; #endif s->method->ssl_clear(s); diff --git a/ssl/s3_srvr.c b/ssl/s3_srvr.c index 7376fe61ec..223a76428e 100644 --- a/ssl/s3_srvr.c +++ b/ssl/s3_srvr.c @@ -227,7 +227,7 @@ int ssl3_accept(SSL *s) /* init things to blank */ s->in_handshake++; if (!SSL_in_init(s) || SSL_in_before(s)) { - if(!SSL_clear(s)) + if (!SSL_clear(s)) return -1; } @@ -882,7 +882,7 @@ int ssl3_send_hello_request(SSL *s) { if (s->state == SSL3_ST_SW_HELLO_REQ_A) { - if(!ssl_set_handshake_header(s, SSL3_MT_HELLO_REQUEST, 0)) { + if (!ssl_set_handshake_header(s, SSL3_MT_HELLO_REQUEST, 0)) { SSLerr(SSL_F_SSL3_SEND_HELLO_REQUEST, ERR_R_INTERNAL_ERROR); return -1; } @@ -1541,7 +1541,7 @@ int ssl3_send_server_hello(SSL *s) #endif /* do the header */ l = (p - d); - if(!ssl_set_handshake_header(s, SSL3_MT_SERVER_HELLO, l)) { + if (!ssl_set_handshake_header(s, SSL3_MT_SERVER_HELLO, l)) { SSLerr(SSL_F_SSL3_SEND_SERVER_HELLO, ERR_R_INTERNAL_ERROR); return -1; } @@ -1556,7 +1556,7 @@ int ssl3_send_server_done(SSL *s) { if (s->state == SSL3_ST_SW_SRVR_DONE_A) { - if(!ssl_set_handshake_header(s, SSL3_MT_SERVER_DONE, 0)) { + if (!ssl_set_handshake_header(s, SSL3_MT_SERVER_DONE, 0)) { SSLerr(SSL_F_SSL3_SEND_SERVER_DONE, ERR_R_INTERNAL_ERROR); return -1; } @@ -2006,7 +2006,7 @@ int ssl3_send_server_key_exchange(SSL *s) } } - if(!ssl_set_handshake_header(s, SSL3_MT_SERVER_KEY_EXCHANGE, n)) { + if (!ssl_set_handshake_header(s, SSL3_MT_SERVER_KEY_EXCHANGE, n)) { al = SSL_AD_HANDSHAKE_FAILURE; SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR); goto f_err; @@ -2088,7 +2088,7 @@ int ssl3_send_certificate_request(SSL *s) p = ssl_handshake_start(s) + off; s2n(nl, p); - if(!ssl_set_handshake_header(s, SSL3_MT_CERTIFICATE_REQUEST, n)) { + if (!ssl_set_handshake_header(s, SSL3_MT_CERTIFICATE_REQUEST, n)) { SSLerr(SSL_F_SSL3_SEND_CERTIFICATE_REQUEST, ERR_R_INTERNAL_ERROR); return -1; } @@ -2278,7 +2278,7 @@ int ssl3_get_client_key_exchange(SSL *s) sizeof (rand_premaster_secret)); OPENSSL_cleanse(p, sizeof(rand_premaster_secret)); - if(s->session->master_key_length < 0) { + if (s->session->master_key_length < 0) { al = SSL_AD_INTERNAL_ERROR; SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR); goto f_err; @@ -2375,7 +2375,7 @@ int ssl3_get_client_key_exchange(SSL *s) session->master_key, p, i); OPENSSL_cleanse(p, i); - if(s->session->master_key_length < 0) { + if (s->session->master_key_length < 0) { al = SSL_AD_INTERNAL_ERROR; SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR); goto f_err; @@ -2545,7 +2545,7 @@ int ssl3_get_client_key_exchange(SSL *s) s-> session->master_key, pms, outl); - if(s->session->master_key_length < 0) { + if (s->session->master_key_length < 0) { al = SSL_INTERNAL_ERROR; SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR); goto f_err; @@ -2698,7 +2698,7 @@ int ssl3_get_client_key_exchange(SSL *s) p, i); OPENSSL_cleanse(p, i); - if(s->session->master_key_length < 0) { + if (s->session->master_key_length < 0) { al = SSL_AD_INTERNAL_ERROR; SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR); goto f_err; @@ -2787,7 +2787,7 @@ int ssl3_get_client_key_exchange(SSL *s) session->master_key, psk_or_pre_ms, pre_ms_len); - if(s->session->master_key_length < 0) { + if (s->session->master_key_length < 0) { al = SSL_AD_INTERNAL_ERROR; SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR); goto psk_err; @@ -2893,7 +2893,7 @@ int ssl3_get_client_key_exchange(SSL *s) s-> session->master_key, premaster_secret, 32); - if(s->session->master_key_length < 0) { + if (s->session->master_key_length < 0) { al = SSL_AD_INTERNAL_ERROR; SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE, ERR_R_INTERNAL_ERROR); goto f_err; @@ -3469,7 +3469,7 @@ int ssl3_send_newsession_ticket(SSL *s) /* Skip ticket lifetime hint */ p = ssl_handshake_start(s) + 4; s2n(len - 6, p); - if(!ssl_set_handshake_header(s, SSL3_MT_NEWSESSION_TICKET, len)) + if (!ssl_set_handshake_header(s, SSL3_MT_NEWSESSION_TICKET, len)) goto err; s->state = SSL3_ST_SW_SESSION_TICKET_B; OPENSSL_free(senc); diff --git a/ssl/ssl_ciph.c b/ssl/ssl_ciph.c index 0f6758bb52..cd86fcc3e1 100644 --- a/ssl/ssl_ciph.c +++ b/ssl/ssl_ciph.c @@ -533,7 +533,7 @@ int ssl_cipher_get_evp(const SSL_SESSION *s, const EVP_CIPHER **enc, *comp = NULL; } /* If were only interested in comp then return success */ - if((enc == NULL) && (md == NULL)) + if ((enc == NULL) && (md == NULL)) return 1; } diff --git a/ssl/ssl_lib.c b/ssl/ssl_lib.c index 42ee3a918c..35a3c9d7b8 100644 --- a/ssl/ssl_lib.c +++ b/ssl/ssl_lib.c @@ -381,7 +381,7 @@ SSL *SSL_new(SSL_CTX *ctx) s->references = 1; s->server = (ctx->method->ssl_accept == ssl_undefined_function) ? 0 : 1; - if(!SSL_clear(s)) + if (!SSL_clear(s)) goto err; CRYPTO_new_ex_data(CRYPTO_EX_INDEX_SSL, s, &s->ex_data); @@ -884,7 +884,7 @@ STACK_OF(X509) *SSL_get_peer_cert_chain(const SSL *s) int SSL_copy_session_id(SSL *t, const SSL *f) { /* Do we need to to SSL locking? */ - if(!SSL_set_session(t, SSL_get_session(f))) { + if (!SSL_set_session(t, SSL_get_session(f))) { return 0; } @@ -900,7 +900,7 @@ int SSL_copy_session_id(SSL *t, const SSL *f) CRYPTO_add(&f->cert->references, 1, CRYPTO_LOCK_SSL_CERT); ssl_cert_free(t->cert); t->cert = f->cert; - if(!SSL_set_session_id_context(t, f->sid_ctx, f->sid_ctx_length)) { + if (!SSL_set_session_id_context(t, f->sid_ctx, f->sid_ctx_length)) { return 0; } @@ -1920,7 +1920,7 @@ SSL_CTX *SSL_CTX_new(const SSL_METHOD *meth) if (ret->cert_store == NULL) goto err; - if(!ssl_create_cipher_list(ret->method, + if (!ssl_create_cipher_list(ret->method, &ret->cipher_list, &ret->cipher_list_by_id, SSL_DEFAULT_CIPHER_LIST, ret->cert) || sk_SSL_CIPHER_num(ret->cipher_list) <= 0) { @@ -1976,7 +1976,7 @@ SSL_CTX *SSL_CTX_new(const SSL_METHOD *meth) ret->psk_server_callback = NULL; #endif #ifndef OPENSSL_NO_SRP - if(!SSL_CTX_SRP_CTX_init(ret)) + if (!SSL_CTX_SRP_CTX_init(ret)) goto err; #endif #ifndef OPENSSL_NO_ENGINE @@ -2756,7 +2756,7 @@ SSL *SSL_dup(SSL *s) if (s->session != NULL) { /* This copies session-id, SSL_METHOD, sid_ctx, and 'cert' */ - if(!SSL_copy_session_id(ret, s)) + if (!SSL_copy_session_id(ret, s)) goto err; } else { /* @@ -2777,7 +2777,7 @@ SSL *SSL_dup(SSL *s) goto err; } - if(!SSL_set_session_id_context(ret, s->sid_ctx, s->sid_ctx_length)) + if (!SSL_set_session_id_context(ret, s->sid_ctx, s->sid_ctx_length)) goto err; } diff --git a/ssl/ssl_rsa.c b/ssl/ssl_rsa.c index 90fe8c8af9..b5d457a9eb 100644 --- a/ssl/ssl_rsa.c +++ b/ssl/ssl_rsa.c @@ -687,7 +687,7 @@ int SSL_CTX_use_certificate_chain_file(SSL_CTX *ctx, const char *file) int r; unsigned long err; - if(!SSL_CTX_clear_chain_certs(ctx)) { + if (!SSL_CTX_clear_chain_certs(ctx)) { ret = 0; goto end; } diff --git a/ssl/ssl_sess.c b/ssl/ssl_sess.c index 3d0f95090d..483c7787a2 100644 --- a/ssl/ssl_sess.c +++ b/ssl/ssl_sess.c @@ -518,7 +518,7 @@ int ssl_get_prev_session(SSL *s, unsigned char *session_id, int len, * The following should not return 1, otherwise, things are * very strange */ - if(SSL_CTX_add_session(s->session_ctx, ret)) + if (SSL_CTX_add_session(s->session_ctx, ret)) goto err; } } @@ -861,7 +861,7 @@ void SSL_SESSION_get0_ticket(const SSL_SESSION *s, unsigned char **tick, size_t *len) { *len = s->tlsext_ticklen; - if(tick != NULL) + if (tick != NULL) *tick = s->tlsext_tick; } diff --git a/ssl/ssl_txt.c b/ssl/ssl_txt.c index ccdf8ec257..9277d2ca58 100644 --- a/ssl/ssl_txt.c +++ b/ssl/ssl_txt.c @@ -214,7 +214,7 @@ int SSL_SESSION_print(BIO *bp, const SSL_SESSION *x) if (x->compress_meth != 0) { SSL_COMP *comp = NULL; - if(!ssl_cipher_get_evp(x, NULL, NULL, NULL, NULL, &comp, 0)) + if (!ssl_cipher_get_evp(x, NULL, NULL, NULL, NULL, &comp, 0)) goto err; if (comp == NULL) { if (BIO_printf(bp, "\n Compression: %d", x->compress_meth) <= diff --git a/ssl/t1_enc.c b/ssl/t1_enc.c index 19b79e9b51..6e926d4bf7 100644 --- a/ssl/t1_enc.c +++ b/ssl/t1_enc.c @@ -260,7 +260,7 @@ static int tls1_PRF(long digest_mask, if ((m << TLS1_PRF_DGST_SHIFT) & digest_mask) count++; } - if(!count) { + if (!count) { /* Should never happen */ SSLerr(SSL_F_TLS1_PRF, ERR_R_INTERNAL_ERROR); goto err; @@ -801,7 +801,7 @@ int tls1_generate_master_secret(SSL *s, unsigned char *out, unsigned char *p, * exchange and before certificate verify) */ s->s3->flags |= TLS1_FLAGS_KEEP_HANDSHAKE; - if(!ssl3_digest_cached_records(s)) + if (!ssl3_digest_cached_records(s)) return -1; } hashlen = ssl_handshake_hash(s, hash, sizeof(hash)); diff --git a/ssl/t1_lib.c b/ssl/t1_lib.c index aef0ef6659..985c357563 100644 --- a/ssl/t1_lib.c +++ b/ssl/t1_lib.c @@ -1606,7 +1606,7 @@ unsigned char *ssl_add_serverhello_tlsext(SSL *s, unsigned char *buf, int el; /* Returns 0 on success!! */ - if(ssl_add_serverhello_use_srtp_ext(s, 0, &el, 0)) { + if (ssl_add_serverhello_use_srtp_ext(s, 0, &el, 0)) { SSLerr(SSL_F_SSL_ADD_SERVERHELLO_TLSEXT, ERR_R_INTERNAL_ERROR); return NULL; } diff --git a/test/hmactest.c b/test/hmactest.c index 5e90dba55a..13344d69e5 100644 --- a/test/hmactest.c +++ b/test/hmactest.c @@ -166,22 +166,22 @@ int main(int argc, char *argv[]) /* test4 */ HMAC_CTX_init(&ctx); - if(HMAC_Init_ex(&ctx, NULL, 0, NULL, NULL)) { + if (HMAC_Init_ex(&ctx, NULL, 0, NULL, NULL)) { printf("Should fail to initialise HMAC with empty MD and key (test 4)\n"); err++; goto test5; } - if(HMAC_Update(&ctx, test[4].data, test[4].data_len)) { + if (HMAC_Update(&ctx, test[4].data, test[4].data_len)) { printf("Should fail HMAC_Update with ctx not set up (test 4)\n"); err++; goto test5; } - if(HMAC_Init_ex(&ctx, NULL, 0, EVP_sha1(), NULL)) { + if (HMAC_Init_ex(&ctx, NULL, 0, EVP_sha1(), NULL)) { printf("Should fail to initialise HMAC with empty key (test 4)\n"); err++; goto test5; } - if(HMAC_Update(&ctx, test[4].data, test[4].data_len)) { + if (HMAC_Update(&ctx, test[4].data, test[4].data_len)) { printf("Should fail HMAC_Update with ctx not set up (test 4)\n"); err++; goto test5; @@ -189,32 +189,32 @@ int main(int argc, char *argv[]) printf("test 4 ok\n"); test5: HMAC_CTX_init(&ctx); - if(HMAC_Init_ex(&ctx, test[4].key, test[4].key_len, NULL, NULL)) { + if (HMAC_Init_ex(&ctx, test[4].key, test[4].key_len, NULL, NULL)) { printf("Should fail to initialise HMAC with empty MD (test 5)\n"); err++; goto test6; } - if(HMAC_Update(&ctx, test[4].data, test[4].data_len)) { + if (HMAC_Update(&ctx, test[4].data, test[4].data_len)) { printf("Should fail HMAC_Update with ctx not set up (test 5)\n"); err++; goto test6; } - if(HMAC_Init_ex(&ctx, test[4].key, -1, EVP_sha1(), NULL)) { + if (HMAC_Init_ex(&ctx, test[4].key, -1, EVP_sha1(), NULL)) { printf("Should fail to initialise HMAC with invalid key len(test 5)\n"); err++; goto test6; } - if(!HMAC_Init_ex(&ctx, test[4].key, test[4].key_len, EVP_sha1(), NULL)) { + if (!HMAC_Init_ex(&ctx, test[4].key, test[4].key_len, EVP_sha1(), NULL)) { printf("Failed to initialise HMAC (test 5)\n"); err++; goto test6; } - if(!HMAC_Update(&ctx, test[4].data, test[4].data_len)) { + if (!HMAC_Update(&ctx, test[4].data, test[4].data_len)) { printf("Error updating HMAC with data (test 5)\n"); err++; goto test6; } - if(!HMAC_Final(&ctx, buf, &len)) { + if (!HMAC_Final(&ctx, buf, &len)) { printf("Error finalising data (test 5)\n"); err++; goto test6; @@ -226,17 +226,17 @@ test5: err++; goto test6; } - if(!HMAC_Init_ex(&ctx, NULL, 0, EVP_sha256(), NULL)) { + if (!HMAC_Init_ex(&ctx, NULL, 0, EVP_sha256(), NULL)) { printf("Failed to reinitialise HMAC (test 5)\n"); err++; goto test6; } - if(!HMAC_Update(&ctx, test[5].data, test[5].data_len)) { + if (!HMAC_Update(&ctx, test[5].data, test[5].data_len)) { printf("Error updating HMAC with data (sha256) (test 5)\n"); err++; goto test6; } - if(!HMAC_Final(&ctx, buf, &len)) { + if (!HMAC_Final(&ctx, buf, &len)) { printf("Error finalising data (sha256) (test 5)\n"); err++; goto test6; @@ -248,17 +248,17 @@ test5: err++; goto test6; } - if(!HMAC_Init_ex(&ctx, test[6].key, test[6].key_len, NULL, NULL)) { + if (!HMAC_Init_ex(&ctx, test[6].key, test[6].key_len, NULL, NULL)) { printf("Failed to reinitialise HMAC with key (test 5)\n"); err++; goto test6; } - if(!HMAC_Update(&ctx, test[6].data, test[6].data_len)) { + if (!HMAC_Update(&ctx, test[6].data, test[6].data_len)) { printf("Error updating HMAC with data (new key) (test 5)\n"); err++; goto test6; } - if(!HMAC_Final(&ctx, buf, &len)) { + if (!HMAC_Final(&ctx, buf, &len)) { printf("Error finalising data (new key) (test 5)\n"); err++; goto test6; @@ -273,22 +273,22 @@ test5: } test6: HMAC_CTX_init(&ctx); - if(!HMAC_Init_ex(&ctx, test[7].key, test[7].key_len, EVP_sha1(), NULL)) { + if (!HMAC_Init_ex(&ctx, test[7].key, test[7].key_len, EVP_sha1(), NULL)) { printf("Failed to initialise HMAC (test 6)\n"); err++; goto end; } - if(!HMAC_Update(&ctx, test[7].data, test[7].data_len)) { + if (!HMAC_Update(&ctx, test[7].data, test[7].data_len)) { printf("Error updating HMAC with data (test 6)\n"); err++; goto end; } - if(!HMAC_CTX_copy(&ctx2, &ctx)) { + if (!HMAC_CTX_copy(&ctx2, &ctx)) { printf("Failed to copy HMAC_CTX (test 6)\n"); err++; goto end; } - if(!HMAC_Final(&ctx2, buf, &len)) { + if (!HMAC_Final(&ctx2, buf, &len)) { printf("Error finalising data (test 6)\n"); err++; goto end; diff --git a/test/ssltest.c b/test/ssltest.c index 25bec77031..6ca99aeaf9 100644 --- a/test/ssltest.c +++ b/test/ssltest.c @@ -1445,7 +1445,7 @@ int main(int argc, char *argv[]) SSL_CTX_set_security_level(s_ctx, 0); if (cipher != NULL) { - if(!SSL_CTX_set_cipher_list(c_ctx, cipher) + if (!SSL_CTX_set_cipher_list(c_ctx, cipher) || !SSL_CTX_set_cipher_list(s_ctx, cipher)) { ERR_print_errors(bio_err); goto end; @@ -1542,7 +1542,7 @@ int main(int argc, char *argv[]) } if (client_auth) { - if(!SSL_CTX_use_certificate_file(c_ctx, client_cert, SSL_FILETYPE_PEM) + if (!SSL_CTX_use_certificate_file(c_ctx, client_cert, SSL_FILETYPE_PEM) || !SSL_CTX_use_PrivateKey_file(c_ctx, (client_key ? client_key : client_cert), SSL_FILETYPE_PEM)) { @@ -1577,7 +1577,7 @@ int main(int argc, char *argv[]) { int session_id_context = 0; - if(!SSL_CTX_set_session_id_context(s_ctx, (void *)&session_id_context, + if (!SSL_CTX_set_session_id_context(s_ctx, (void *)&session_id_context, sizeof session_id_context)) { ERR_print_errors(bio_err); goto end; @@ -1649,7 +1649,7 @@ int main(int argc, char *argv[]) #endif if (serverinfo_sct) { - if(!SSL_CTX_add_client_custom_ext(c_ctx, SCT_EXT_TYPE, + if (!SSL_CTX_add_client_custom_ext(c_ctx, SCT_EXT_TYPE, NULL, NULL, NULL, serverinfo_cli_parse_cb, NULL)) { BIO_printf(bio_err, "Error adding SCT extension\n"); @@ -1657,7 +1657,7 @@ int main(int argc, char *argv[]) } } if (serverinfo_tack) { - if(!SSL_CTX_add_client_custom_ext(c_ctx, TACK_EXT_TYPE, + if (!SSL_CTX_add_client_custom_ext(c_ctx, TACK_EXT_TYPE, NULL, NULL, NULL, serverinfo_cli_parse_cb, NULL)) { BIO_printf(bio_err, "Error adding TACK extension\n"); @@ -1671,35 +1671,35 @@ int main(int argc, char *argv[]) } if (custom_ext) { - if(!SSL_CTX_add_client_custom_ext(c_ctx, CUSTOM_EXT_TYPE_0, + if (!SSL_CTX_add_client_custom_ext(c_ctx, CUSTOM_EXT_TYPE_0, custom_ext_0_cli_add_cb, NULL, NULL, custom_ext_0_cli_parse_cb, NULL) - || !SSL_CTX_add_client_custom_ext(c_ctx, CUSTOM_EXT_TYPE_1, + || !SSL_CTX_add_client_custom_ext(c_ctx, CUSTOM_EXT_TYPE_1, custom_ext_1_cli_add_cb, NULL, NULL, custom_ext_1_cli_parse_cb, NULL) - || !SSL_CTX_add_client_custom_ext(c_ctx, CUSTOM_EXT_TYPE_2, + || !SSL_CTX_add_client_custom_ext(c_ctx, CUSTOM_EXT_TYPE_2, custom_ext_2_cli_add_cb, NULL, NULL, custom_ext_2_cli_parse_cb, NULL) - || !SSL_CTX_add_client_custom_ext(c_ctx, CUSTOM_EXT_TYPE_3, + || !SSL_CTX_add_client_custom_ext(c_ctx, CUSTOM_EXT_TYPE_3, custom_ext_3_cli_add_cb, NULL, NULL, custom_ext_3_cli_parse_cb, NULL) - || !SSL_CTX_add_server_custom_ext(s_ctx, CUSTOM_EXT_TYPE_0, + || !SSL_CTX_add_server_custom_ext(s_ctx, CUSTOM_EXT_TYPE_0, custom_ext_0_srv_add_cb, NULL, NULL, custom_ext_0_srv_parse_cb, NULL) - || !SSL_CTX_add_server_custom_ext(s_ctx, CUSTOM_EXT_TYPE_1, + || !SSL_CTX_add_server_custom_ext(s_ctx, CUSTOM_EXT_TYPE_1, custom_ext_1_srv_add_cb, NULL, NULL, custom_ext_1_srv_parse_cb, NULL) - || !SSL_CTX_add_server_custom_ext(s_ctx, CUSTOM_EXT_TYPE_2, + || !SSL_CTX_add_server_custom_ext(s_ctx, CUSTOM_EXT_TYPE_2, custom_ext_2_srv_add_cb, NULL, NULL, custom_ext_2_srv_parse_cb, NULL) - || !SSL_CTX_add_server_custom_ext(s_ctx, CUSTOM_EXT_TYPE_3, + || !SSL_CTX_add_server_custom_ext(s_ctx, CUSTOM_EXT_TYPE_3, custom_ext_3_srv_add_cb, NULL, NULL, custom_ext_3_srv_parse_cb, NULL)) { @@ -1720,7 +1720,7 @@ int main(int argc, char *argv[]) goto end; } /* Returns 0 on success!! */ - if(SSL_CTX_set_alpn_protos(c_ctx, alpn, alpn_len)) { + if (SSL_CTX_set_alpn_protos(c_ctx, alpn, alpn_len)) { BIO_printf(bio_err, "Error setting ALPN\n"); OPENSSL_free(alpn); goto end; @@ -1748,7 +1748,7 @@ int main(int argc, char *argv[]) for (i = 0; i < number; i++) { if (!reuse) { - if(!SSL_set_session(c_ssl, NULL)) { + if (!SSL_set_session(c_ssl, NULL)) { BIO_printf(bio_err, "Failed to set session\n"); goto end; } -- 2.25.1