From: tb Date: Sun, 9 Apr 2023 17:28:52 +0000 (+0000) Subject: Minor code cleanup X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=5c31e3d80e53be27b7fb7c2408ad7af0cb229e04;p=openbsd Minor code cleanup Unwrap a few awkwardly wrapped lines, drop redundant parentheses and add empty lines after some variable declarations. No change in the generated assembly. --- diff --git a/usr.bin/openssl/x509.c b/usr.bin/openssl/x509.c index 66cad3ab2cd..e6d1ee915db 100644 --- a/usr.bin/openssl/x509.c +++ b/usr.bin/openssl/x509.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509.c,v 1.31 2023/03/06 14:32:06 tb Exp $ */ +/* $OpenBSD: x509.c,v 1.32 2023/04/09 17:28:52 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -772,10 +772,9 @@ x509_main(int argc, char **argv) ERR_print_errors(bio_err); goto end; } - if ((cfg.CAkeyfile == NULL) && (cfg.CA_flag) && - (cfg.CAformat == FORMAT_PEM)) { + if (cfg.CAkeyfile == NULL && cfg.CA_flag && cfg.CAformat == FORMAT_PEM) { cfg.CAkeyfile = cfg.CAfile; - } else if ((cfg.CA_flag) && (cfg.CAkeyfile == NULL)) { + } else if (cfg.CA_flag && cfg.CAkeyfile == NULL) { BIO_printf(bio_err, "need to specify a CAkey if using the CA command\n"); goto end; @@ -796,8 +795,8 @@ x509_main(int argc, char **argv) goto end; } if (cfg.extsect == NULL) { - cfg.extsect = NCONF_get_string(extconf, - "default", "extensions"); + cfg.extsect = NCONF_get_string(extconf, "default", + "extensions"); if (cfg.extsect == NULL) { ERR_clear_error(); cfg.extsect = "default"; @@ -805,11 +804,9 @@ x509_main(int argc, char **argv) } X509V3_set_ctx_test(&ctx2); X509V3_set_nconf(&ctx2, extconf); - if (!X509V3_EXT_add_nconf(extconf, &ctx2, cfg.extsect, - NULL)) { + if (!X509V3_EXT_add_nconf(extconf, &ctx2, cfg.extsect, NULL)) { BIO_printf(bio_err, - "Error Loading extension section %s\n", - cfg.extsect); + "Error Loading extension section %s\n", cfg.extsect); ERR_print_errors(bio_err); goto end; } @@ -869,8 +866,7 @@ x509_main(int argc, char **argv) if (cfg.sno == NULL) { cfg.sno = ASN1_INTEGER_new(); - if (cfg.sno == NULL || - !rand_serial(NULL, cfg.sno)) + if (cfg.sno == NULL || !rand_serial(NULL, cfg.sno)) goto end; if (!X509_set_serialNumber(x, cfg.sno)) goto end; @@ -897,15 +893,15 @@ x509_main(int argc, char **argv) goto end; } } else { - x = load_cert(bio_err, cfg.infile, cfg.informat, - NULL, "Certificate"); + x = load_cert(bio_err, cfg.infile, cfg.informat, NULL, + "Certificate"); } if (x == NULL) goto end; if (cfg.CA_flag) { - xca = load_cert(bio_err, cfg.CAfile, - cfg.CAformat, NULL, "CA Certificate"); + xca = load_cert(bio_err, cfg.CAfile, cfg.CAformat, NULL, + "CA Certificate"); if (xca == NULL) goto end; } @@ -938,16 +934,14 @@ x509_main(int argc, char **argv) if (cfg.trust != NULL) { for (i = 0; i < sk_ASN1_OBJECT_num(cfg.trust); i++) { - cfg.objtmp = sk_ASN1_OBJECT_value( - cfg.trust, i); + cfg.objtmp = sk_ASN1_OBJECT_value(cfg.trust, i); if (!X509_add1_trust_object(x, cfg.objtmp)) goto end; } } if (cfg.reject != NULL) { for (i = 0; i < sk_ASN1_OBJECT_num(cfg.reject); i++) { - cfg.objtmp = sk_ASN1_OBJECT_value( - cfg.reject, i); + cfg.objtmp = sk_ASN1_OBJECT_value(cfg.reject, i); if (!X509_add1_reject_object(x, cfg.objtmp)) goto end; } @@ -956,12 +950,10 @@ x509_main(int argc, char **argv) for (i = 1; i <= cfg.num; i++) { if (cfg.issuer == i) { print_name(STDout, "issuer= ", - X509_get_issuer_name(x), - cfg.nmflag); + X509_get_issuer_name(x), cfg.nmflag); } else if (cfg.subject == i) { print_name(STDout, "subject= ", - X509_get_subject_name(x), - cfg.nmflag); + X509_get_subject_name(x), cfg.nmflag); } else if (cfg.serial == i) { BIO_printf(STDout, "serial="); i2a_ASN1_INTEGER(STDout, @@ -970,6 +962,7 @@ x509_main(int argc, char **argv) } else if (cfg.next_serial == i) { BIGNUM *bnser; ASN1_INTEGER *ser; + ser = X509_get_serialNumber(x); if (ser == NULL) goto end; @@ -989,10 +982,10 @@ x509_main(int argc, char **argv) i2a_ASN1_INTEGER(out, ser); ASN1_INTEGER_free(ser); BIO_puts(out, "\n"); - } else if ((cfg.email == i) || - (cfg.ocsp_uri == i)) { - int j; + } else if (cfg.email == i || cfg.ocsp_uri == i) { STACK_OF(OPENSSL_STRING) *emlst; + int j; + if (cfg.email == i) emlst = X509_get1_email(x); else @@ -1033,6 +1026,7 @@ x509_main(int argc, char **argv) else if (cfg.pprint == i) { X509_PURPOSE *ptmp; int j; + BIO_printf(STDout, "Certificate purposes:\n"); for (j = 0; j < X509_PURPOSE_get_count(); j++) { ptmp = X509_PURPOSE_get0(j); @@ -1162,6 +1156,7 @@ x509_main(int argc, char **argv) goto end; } else if (cfg.startdate == i) { ASN1_TIME *nB = X509_get_notBefore(x); + BIO_puts(STDout, "notBefore="); if (ASN1_time_parse(nB->data, nB->length, NULL, 0) == -1) @@ -1172,6 +1167,7 @@ x509_main(int argc, char **argv) BIO_puts(STDout, "\n"); } else if (cfg.enddate == i) { ASN1_TIME *nA = X509_get_notAfter(x); + BIO_puts(STDout, "notAfter="); if (ASN1_time_parse(nA->data, nA->length, NULL, 0) == -1) @@ -1201,12 +1197,10 @@ x509_main(int argc, char **argv) } /* should be in the library */ - } else if ((cfg.sign_flag == i) && - (cfg.x509req == 0)) { + } else if (cfg.sign_flag == i && cfg.x509req == 0) { BIO_printf(bio_err, "Getting Private key\n"); if (Upkey == NULL) { - Upkey = load_key(bio_err, - cfg.keyfile, + Upkey = load_key(bio_err, cfg.keyfile, cfg.keyformat, 0, passin, "Private key"); if (Upkey == NULL) @@ -1219,20 +1213,16 @@ x509_main(int argc, char **argv) } else if (cfg.CA_flag == i) { BIO_printf(bio_err, "Getting CA Private Key\n"); if (cfg.CAkeyfile != NULL) { - CApkey = load_key(bio_err, - cfg.CAkeyfile, + CApkey = load_key(bio_err, cfg.CAkeyfile, cfg.CAkeyformat, 0, passin, "CA Private Key"); if (CApkey == NULL) goto end; } - if (!x509_certify(ctx, cfg.CAfile, - cfg.digest, x, xca, CApkey, - cfg.sigopts, cfg.CAserial, - cfg.CA_createserial, - cfg.days, cfg.clrext, - extconf, cfg.extsect, - cfg.sno)) + if (!x509_certify(ctx, cfg.CAfile, cfg.digest, + x, xca, CApkey, cfg.sigopts, cfg.CAserial, + cfg.CA_createserial, cfg.days, cfg.clrext, + extconf, cfg.extsect, cfg.sno)) goto end; } else if (cfg.x509req == i) { EVP_PKEY *pk; @@ -1244,8 +1234,7 @@ x509_main(int argc, char **argv) "no request key file specified\n"); goto end; } else { - pk = load_key(bio_err, - cfg.keyfile, + pk = load_key(bio_err, cfg.keyfile, cfg.keyformat, 0, passin, "request key"); if (pk == NULL)