More KNF.
authorjsing <jsing@openbsd.org>
Tue, 22 Apr 2014 13:32:17 +0000 (13:32 +0000)
committerjsing <jsing@openbsd.org>
Tue, 22 Apr 2014 13:32:17 +0000 (13:32 +0000)
lib/libssl/src/apps/ca.c
lib/libssl/src/apps/ciphers.c
lib/libssl/src/apps/cms.c
lib/libssl/src/apps/crl.c
lib/libssl/src/apps/crl2p7.c
lib/libssl/src/apps/s_cb.c

index de858d5..ccd5225 100644 (file)
@@ -2125,7 +2125,7 @@ certify_spkac(X509 ** xret, char *infile, EVP_PKEY * pkey, X509 * x509,
        ri = req->req_info;
        n = ri->subject;
 
-       for (i = 0; ; i++) {
+       for (i = 0;; i++) {
                if (sk_CONF_VALUE_num(sk) <= i)
                        break;
 
index d7ee87a..ef2da82 100644 (file)
@@ -149,7 +149,7 @@ ciphers_main(int argc, char **argv)
 
 
        if (!verbose) {
-               for (i = 0;; i++) {
+               for (i = 0; ; i++) {
                        p = SSL_get_cipher_list(ssl, i);
                        if (p == NULL)
                                break;
@@ -180,7 +180,8 @@ ciphers_main(int argc, char **argv)
                                else
                                        BIO_printf(STDout, "0x%02X,0x%02X,0x%02X,0x%02X - ", id0, id1, id2, id3);       /* whatever */
                        }
-                       BIO_puts(STDout, SSL_CIPHER_description(c, buf, sizeof buf));
+                       BIO_puts(STDout,
+                           SSL_CIPHER_description(c, buf, sizeof buf));
                }
        }
 
@@ -190,6 +191,7 @@ err:
                SSL_load_error_strings();
                ERR_print_errors(bio_err);
        }
+
 end:
        if (ctx != NULL)
                SSL_CTX_free(ctx);
index 0ece401..8828a24 100644 (file)
@@ -69,9 +69,8 @@
 static int save_certs(char *signerfile, STACK_OF(X509) * signers);
 static int cms_cb(int ok, X509_STORE_CTX * ctx);
 static void receipt_request_print(BIO * out, CMS_ContentInfo * cms);
-static CMS_ReceiptRequest *
-    make_receipt_request(STACK_OF(OPENSSL_STRING) * rr_to,
-    int rr_allorfirst,
+static CMS_ReceiptRequest * make_receipt_request(
+    STACK_OF(OPENSSL_STRING) * rr_to, int rr_allorfirst,
     STACK_OF(OPENSSL_STRING) * rr_from);
 
 #define SMIME_OP       0x10
@@ -361,7 +360,8 @@ cms_main(int argc, char **argv)
 
                        if (signerfile) {
                                if (!sksigners)
-                                       sksigners = sk_OPENSSL_STRING_new_null();
+                                       sksigners =
+                                           sk_OPENSSL_STRING_new_null();
                                sk_OPENSSL_STRING_push(sksigners, signerfile);
                                if (!keyfile)
                                        keyfile = signerfile;
@@ -394,11 +394,13 @@ cms_main(int argc, char **argv)
                        /* If previous -inkey arument add signer to list */
                        if (keyfile) {
                                if (!signerfile) {
-                                       BIO_puts(bio_err, "Illegal -inkey without -signer\n");
+                                       BIO_puts(bio_err,
+                                           "Illegal -inkey without -signer\n");
                                        goto argerr;
                                }
                                if (!sksigners)
-                                       sksigners = sk_OPENSSL_STRING_new_null();
+                                       sksigners =
+                                           sk_OPENSSL_STRING_new_null();
                                sk_OPENSSL_STRING_push(sksigners, signerfile);
                                signerfile = NULL;
                                if (!skkeys)
@@ -482,19 +484,22 @@ cms_main(int argc, char **argv)
                        sk_OPENSSL_STRING_push(skkeys, keyfile);
                }
                if (!sksigners) {
-                       BIO_printf(bio_err, "No signer certificate specified\n");
+                       BIO_printf(bio_err,
+                           "No signer certificate specified\n");
                        badarg = 1;
                }
                signerfile = NULL;
                keyfile = NULL;
        } else if (operation == SMIME_DECRYPT) {
                if (!recipfile && !keyfile && !secret_key && !pwri_pass) {
-                       BIO_printf(bio_err, "No recipient certificate or key specified\n");
+                       BIO_printf(bio_err,
+                           "No recipient certificate or key specified\n");
                        badarg = 1;
                }
        } else if (operation == SMIME_ENCRYPT) {
                if (!*args && !secret_key && !pwri_pass) {
-                       BIO_printf(bio_err, "No recipient(s) certificate(s) specified\n");
+                       BIO_printf(bio_err,
+                           "No recipient(s) certificate(s) specified\n");
                        badarg = 1;
                }
        } else if (!operation)
@@ -612,7 +617,7 @@ argerr:
                        encerts = sk_X509_new_null();
                while (*args) {
                        if (!(cert = load_cert(bio_err, *args, FORMAT_PEM,
-                                   NULL, e, "recipient certificate file")))
+                           NULL, e, "recipient certificate file")))
                                goto end;
                        sk_X509_push(encerts, cert);
                        cert = NULL;
@@ -621,21 +626,21 @@ argerr:
        }
        if (certfile) {
                if (!(other = load_certs(bio_err, certfile, FORMAT_PEM, NULL,
-                           e, "certificate file"))) {
+                   e, "certificate file"))) {
                        ERR_print_errors(bio_err);
                        goto end;
                }
        }
        if (recipfile && (operation == SMIME_DECRYPT)) {
                if (!(recip = load_cert(bio_err, recipfile, FORMAT_PEM, NULL,
-                           e, "recipient certificate file"))) {
+                   e, "recipient certificate file"))) {
                        ERR_print_errors(bio_err);
                        goto end;
                }
        }
        if (operation == SMIME_SIGN_RECEIPT) {
                if (!(signer = load_cert(bio_err, signerfile, FORMAT_PEM, NULL,
-                           e, "receipt signer certificate file"))) {
+                   e, "receipt signer certificate file"))) {
                        ERR_print_errors(bio_err);
                        goto end;
                }
@@ -643,7 +648,8 @@ argerr:
        if (operation == SMIME_DECRYPT) {
                if (!keyfile)
                        keyfile = recipfile;
-       } else if ((operation == SMIME_SIGN) || (operation == SMIME_SIGN_RECEIPT)) {
+       } else if ((operation == SMIME_SIGN) ||
+           (operation == SMIME_SIGN_RECEIPT)) {
                if (!keyfile)
                        keyfile = signerfile;
        } else
@@ -683,7 +689,8 @@ argerr:
                if (contfile) {
                        BIO_free(indata);
                        if (!(indata = BIO_new_file(contfile, "rb"))) {
-                               BIO_printf(bio_err, "Can't read content file %s\n", contfile);
+                               BIO_printf(bio_err,
+                                   "Can't read content file %s\n", contfile);
                                goto end;
                        }
                }
@@ -733,7 +740,8 @@ argerr:
                out = BIO_new_fp(stdout, BIO_NOCLOSE);
        }
 
-       if ((operation == SMIME_VERIFY) || (operation == SMIME_VERIFY_RECEIPT)) {
+       if ((operation == SMIME_VERIFY) ||
+           (operation == SMIME_VERIFY_RECEIPT)) {
                if (!(store = setup_verify(bio_err, CAfile, CApath)))
                        goto end;
                X509_STORE_set_verify_cb(store, cms_cb);
@@ -754,22 +762,21 @@ argerr:
                if (!cms)
                        goto end;
                if (secret_key) {
-                       if (!CMS_add0_recipient_key(cms, NID_undef,
-                               secret_key, secret_keylen,
-                               secret_keyid, secret_keyidlen,
-                               NULL, NULL, NULL))
+                       if (!CMS_add0_recipient_key(cms, NID_undef, secret_key,
+                           secret_keylen, secret_keyid, secret_keyidlen,
+                           NULL, NULL, NULL))
                                goto end;
                        /* NULL these because call absorbs them */
                        secret_key = NULL;
                        secret_keyid = NULL;
                }
                if (pwri_pass) {
-                       pwri_tmp = (unsigned char *) BUF_strdup((char *) pwri_pass);
+                       pwri_tmp =
+                           (unsigned char *)BUF_strdup((char *)pwri_pass);
                        if (!pwri_tmp)
                                goto end;
-                       if (!CMS_add0_recipient_password(cms,
-                               -1, NID_undef, NID_undef,
-                               pwri_tmp, -1, NULL))
+                       if (!CMS_add0_recipient_password(cms, -1, NID_undef,
+                           NID_undef, pwri_tmp, -1, NULL))
                                goto end;
                        pwri_tmp = NULL;
                }
@@ -778,9 +785,8 @@ argerr:
                                goto end;
                }
        } else if (operation == SMIME_ENCRYPTED_ENCRYPT) {
-               cms = CMS_EncryptedData_encrypt(in, cipher,
-                   secret_key, secret_keylen,
-                   flags);
+               cms = CMS_EncryptedData_encrypt(in, cipher, secret_key,
+                   secret_keylen, flags);
 
        } else if (operation == SMIME_SIGN_RECEIPT) {
                CMS_ContentInfo *srcms = NULL;
@@ -829,8 +835,8 @@ argerr:
                        CMS_SignerInfo *si;
                        signerfile = sk_OPENSSL_STRING_value(sksigners, i);
                        keyfile = sk_OPENSSL_STRING_value(skkeys, i);
-                       signer = load_cert(bio_err, signerfile, FORMAT_PEM, NULL,
-                           e, "signer certificate");
+                       signer = load_cert(bio_err, signerfile, FORMAT_PEM,
+                           NULL, e, "signer certificate");
                        if (!signer)
                                goto end;
                        key = load_key(bio_err, keyfile, keyform, 0, passin, e,
@@ -863,9 +869,8 @@ argerr:
                        CMS_decrypt(cms, NULL, NULL, NULL, NULL, flags);
 
                if (secret_key) {
-                       if (!CMS_decrypt_set1_key(cms,
-                               secret_key, secret_keylen,
-                               secret_keyid, secret_keyidlen)) {
+                       if (!CMS_decrypt_set1_key(cms, secret_key,
+                           secret_keylen, secret_keyid, secret_keyidlen)) {
                                BIO_puts(bio_err,
                                    "Error decrypting CMS using secret key\n");
                                goto end;
@@ -904,7 +909,7 @@ argerr:
                }
        } else if (operation == SMIME_ENCRYPTED_DECRYPT) {
                if (!CMS_EncryptedData_decrypt(cms, secret_key, secret_keylen,
-                       indata, out, flags))
+                   indata, out, flags))
                        goto end;
        } else if (operation == SMIME_VERIFY) {
                if (CMS_verify(cms, other, store, indata, out, flags) > 0)
@@ -966,6 +971,7 @@ argerr:
                }
        }
        ret = 0;
+
 end:
        if (ret)
                ERR_print_errors(bio_err);
@@ -1012,6 +1018,7 @@ save_certs(char *signerfile, STACK_OF(X509) * signers)
 {
        int i;
        BIO *tmp;
+
        if (!signerfile)
                return 1;
        tmp = BIO_new_file(signerfile, "w");
@@ -1023,7 +1030,6 @@ save_certs(char *signerfile, STACK_OF(X509) * signers)
        return 1;
 }
 
-
 /* Minimal callback just to output policy info (if any) */
 
 static int
@@ -1050,6 +1056,7 @@ gnames_stack_print(BIO * out, STACK_OF(GENERAL_NAMES) * gns)
        STACK_OF(GENERAL_NAME) * gens;
        GENERAL_NAME *gen;
        int i, j;
+
        for (i = 0; i < sk_GENERAL_NAMES_num(gns); i++) {
                gens = sk_GENERAL_NAMES_value(gns, i);
                for (j = 0; j < sk_GENERAL_NAME_num(gens); j++) {
@@ -1072,6 +1079,7 @@ receipt_request_print(BIO * out, CMS_ContentInfo * cms)
        STACK_OF(GENERAL_NAMES) * rto, *rlist;
        ASN1_STRING *scid;
        int i, rv;
+
        sis = CMS_get0_SignerInfos(cms);
        for (i = 0; i < sk_CMS_SignerInfo_num(sis); i++) {
                si = sk_CMS_SignerInfo_value(sis, i);
@@ -1109,8 +1117,7 @@ receipt_request_print(BIO * out, CMS_ContentInfo * cms)
        }
 }
 
-static
-STACK_OF(GENERAL_NAMES) *
+static STACK_OF(GENERAL_NAMES) *
 make_names_stack(STACK_OF(OPENSSL_STRING) * ns)
 {
        int i;
@@ -1155,6 +1162,7 @@ make_receipt_request(STACK_OF(OPENSSL_STRING) * rr_to, int rr_allorfirst,
 {
        STACK_OF(GENERAL_NAMES) * rct_to, *rct_from;
        CMS_ReceiptRequest *rr;
+
        rct_to = make_names_stack(rr_to);
        if (!rct_to)
                goto err;
index 07fb1fb..60ce43d 100644 (file)
@@ -110,7 +110,7 @@ crl_main(int argc, char **argv)
        int informat, outformat;
        char *infile = NULL, *outfile = NULL;
        int hash = 0, issuer = 0, lastupdate = 0, nextupdate = 0, noout = 0,
-        text = 0;
+           text = 0;
 #ifndef OPENSSL_NO_MD5
        int hash_old = 0;
 #endif
@@ -235,13 +235,15 @@ bad:
                if (lookup == NULL)
                        goto end;
                if (!X509_LOOKUP_load_file(lookup, CAfile, X509_FILETYPE_PEM))
-                       X509_LOOKUP_load_file(lookup, NULL, X509_FILETYPE_DEFAULT);
+                       X509_LOOKUP_load_file(lookup, NULL,
+                           X509_FILETYPE_DEFAULT);
 
                lookup = X509_STORE_add_lookup(store, X509_LOOKUP_hash_dir());
                if (lookup == NULL)
                        goto end;
                if (!X509_LOOKUP_add_dir(lookup, CApath, X509_FILETYPE_PEM))
-                       X509_LOOKUP_add_dir(lookup, NULL, X509_FILETYPE_DEFAULT);
+                       X509_LOOKUP_add_dir(lookup, NULL,
+                           X509_FILETYPE_DEFAULT);
                ERR_clear_error();
 
                if (!X509_STORE_CTX_init(&ctx, store, NULL, NULL)) {
@@ -275,12 +277,13 @@ bad:
        if (num) {
                for (i = 1; i <= num; i++) {
                        if (issuer == i) {
-                               print_name(bio_out, "issuer=", X509_CRL_get_issuer(x), nmflag);
+                               print_name(bio_out, "issuer=",
+                                   X509_CRL_get_issuer(x), nmflag);
                        }
                        if (crlnumber == i) {
                                ASN1_INTEGER *crlnum;
-                               crlnum = X509_CRL_get_ext_d2i(x, NID_crl_number,
-                                   NULL, NULL);
+                               crlnum = X509_CRL_get_ext_d2i(x,
+                                   NID_crl_number, NULL, NULL);
                                BIO_printf(bio_out, "crlNumber=");
                                if (crlnum) {
                                        i2a_ASN1_INTEGER(bio_out, crlnum);
@@ -296,8 +299,7 @@ bad:
 #ifndef OPENSSL_NO_MD5
                        if (hash_old == i) {
                                BIO_printf(bio_out, "%08lx\n",
-                                   X509_NAME_hash_old(
-                                       X509_CRL_get_issuer(x)));
+                                   X509_NAME_hash_old(X509_CRL_get_issuer(x)));
                        }
 #endif
                        if (lastupdate == i) {
@@ -328,7 +330,7 @@ bad:
                                    OBJ_nid2sn(EVP_MD_type(digest)));
                                for (j = 0; j < (int) n; j++) {
                                        BIO_printf(bio_out, "%02X%c", md[j],
-                                           (j + 1 == (int) n) ? '\n' : ':');
+                                           (j + 1 == (int)n) ? '\n' : ':');
                                }
                        }
                }
@@ -359,7 +361,8 @@ bad:
        else if (outformat == FORMAT_PEM)
                i = PEM_write_bio_X509_CRL(out, x);
        else {
-               BIO_printf(bio_err, "bad output format specified for outfile\n");
+               BIO_printf(bio_err,
+                   "bad output format specified for outfile\n");
                goto end;
        }
        if (!i) {
@@ -405,7 +408,8 @@ load_crl(char *infile, int format)
        else if (format == FORMAT_PEM)
                x = PEM_read_bio_X509_CRL(in, NULL, NULL, NULL);
        else {
-               BIO_printf(bio_err, "bad input format specified for input crl\n");
+               BIO_printf(bio_err,
+                   "bad input format specified for input crl\n");
                goto end;
        }
        if (x == NULL) {
@@ -413,6 +417,7 @@ load_crl(char *infile, int format)
                ERR_print_errors(bio_err);
                goto end;
        }
+
 end:
        BIO_free(in);
        return (x);
index b994c0c..88b4d46 100644 (file)
@@ -181,7 +181,8 @@ bad:
                else if (informat == FORMAT_PEM)
                        crl = PEM_read_bio_X509_CRL(in, NULL, NULL, NULL);
                else {
-                       BIO_printf(bio_err, "bad input format specified for input crl\n");
+                       BIO_printf(bio_err,
+                           "bad input format specified for input crl\n");
                        goto end;
                }
                if (crl == NULL) {
@@ -215,7 +216,8 @@ bad:
                for (i = 0; i < sk_OPENSSL_STRING_num(certflst); i++) {
                        certfile = sk_OPENSSL_STRING_value(certflst, i);
                        if (add_certs_from_file(cert_stack, certfile) < 0) {
-                               BIO_printf(bio_err, "error loading certificates\n");
+                               BIO_printf(bio_err,
+                                   "error loading certificates\n");
                                ERR_print_errors(bio_err);
                                goto end;
                        }
@@ -237,7 +239,8 @@ bad:
        else if (outformat == FORMAT_PEM)
                i = PEM_write_bio_PKCS7(out, p7);
        else {
-               BIO_printf(bio_err, "bad output format specified for outfile\n");
+               BIO_printf(bio_err,
+                   "bad output format specified for outfile\n");
                goto end;
        }
        if (!i) {
index 38ea271..362339c 100644 (file)
@@ -201,7 +201,7 @@ set_cert_stuff(SSL_CTX * ctx, char *cert_file, char *key_file)
                */
 
                if (SSL_CTX_use_certificate_file(ctx, cert_file,
-                       SSL_FILETYPE_PEM) <= 0) {
+                   SSL_FILETYPE_PEM) <= 0) {
                        BIO_printf(bio_err,
                            "unable to get certificate from '%s'\n", cert_file);
                        ERR_print_errors(bio_err);
@@ -210,7 +210,7 @@ set_cert_stuff(SSL_CTX * ctx, char *cert_file, char *key_file)
                if (key_file == NULL)
                        key_file = cert_file;
                if (SSL_CTX_use_PrivateKey_file(ctx, key_file,
-                       SSL_FILETYPE_PEM) <= 0) {
+                   SSL_FILETYPE_PEM) <= 0) {
                        BIO_printf(bio_err,
                            "unable to get private key from '%s'\n", key_file);
                        ERR_print_errors(bio_err);
@@ -341,7 +341,7 @@ msg_cb(int write_p, int version, int content_type, const void *buf, size_t len,
 {
        BIO *bio = arg;
        const char *str_write_p, *str_version, *str_content_type = "",
-       *str_details1 = "", *str_details2 = "";
+           *str_details1 = "", *str_details2 = "";
 
        str_write_p = write_p ? ">>>" : "<<<";