mirror of
https://github.com/PowerShell/Win32-OpenSSH.git
synced 2025-07-26 15:34:37 +02:00
remove white spaces
This commit is contained in:
parent
521a370765
commit
a6aad9eefd
134
ssh-keygen.c
134
ssh-keygen.c
@ -67,7 +67,7 @@
|
||||
# define DEFAULT_KEY_TYPE_NAME "ed25519"
|
||||
#endif
|
||||
|
||||
/* Number of bits in the RSA/DSA key. This value can be set on the command line. */
|
||||
/* Number of bits in the RSA/DSA key. This value can be set on the command line. */
|
||||
#define DEFAULT_BITS 2048
|
||||
#define DEFAULT_BITS_DSA 1024
|
||||
#define DEFAULT_BITS_ECDSA 256
|
||||
@ -221,8 +221,7 @@ type_bits_valid(int type, const char *name, u_int32_t *bitsp)
|
||||
*bitsp = sshkey_curve_nid_to_bits(nid);
|
||||
if (*bitsp == 0)
|
||||
*bitsp = DEFAULT_BITS_ECDSA;
|
||||
}
|
||||
else
|
||||
} else
|
||||
#endif
|
||||
*bitsp = DEFAULT_BITS;
|
||||
}
|
||||
@ -489,11 +488,9 @@ do_convert_private_ssh2_from_blob(u_char *blob, u_int blen)
|
||||
|
||||
if (strstr(type, "dsa")) {
|
||||
ktype = KEY_DSA;
|
||||
}
|
||||
else if (strstr(type, "rsa")) {
|
||||
} else if (strstr(type, "rsa")) {
|
||||
ktype = KEY_RSA;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
sshbuf_free(b);
|
||||
free(type);
|
||||
return NULL;
|
||||
@ -617,10 +614,10 @@ do_convert_from_ssh2(struct passwd *pw, struct sshkey **k, int *private)
|
||||
}
|
||||
len = strlen(encoded);
|
||||
if (((len % 4) == 3) &&
|
||||
(encoded[len - 1] == '=') &&
|
||||
(encoded[len - 2] == '=') &&
|
||||
(encoded[len - 3] == '='))
|
||||
encoded[len - 3] = '\0';
|
||||
(encoded[len-1] == '=') &&
|
||||
(encoded[len-2] == '=') &&
|
||||
(encoded[len-3] == '='))
|
||||
encoded[len-3] = '\0';
|
||||
blen = uudecode(encoded, blob, sizeof(blob));
|
||||
if (blen < 0)
|
||||
fatal("uudecode failed.");
|
||||
@ -739,8 +736,7 @@ do_convert_from(struct passwd *pw)
|
||||
ok = 1;
|
||||
if (ok)
|
||||
fprintf(stdout, "\n");
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
switch (k->type) {
|
||||
case KEY_DSA:
|
||||
ok = PEM_write_DSAPrivateKey(stdout, k->dsa, NULL,
|
||||
@ -818,9 +814,8 @@ do_download(struct passwd *pw)
|
||||
printf("%s\n", ra);
|
||||
free(ra);
|
||||
free(fp);
|
||||
}
|
||||
else {
|
||||
(void)sshkey_write(keys[i], stdout); /* XXX check */
|
||||
} else {
|
||||
(void) sshkey_write(keys[i], stdout); /* XXX check */
|
||||
fprintf(stdout, "\n");
|
||||
}
|
||||
sshkey_free(keys[i]);
|
||||
@ -910,8 +905,7 @@ do_fingerprint(struct passwd *pw)
|
||||
if (strcmp(identity_file, "-") == 0) {
|
||||
f = stdin;
|
||||
path = "(stdin)";
|
||||
}
|
||||
else if ((f = fopen(path, "r")) == NULL)
|
||||
} else if ((f = fopen(path, "r")) == NULL)
|
||||
fatal("%s: %s: %s", __progname, path, strerror(errno));
|
||||
|
||||
while (read_keyfile_line(f, path, line, sizeof(line), &lnum) == 0) {
|
||||
@ -1023,8 +1017,7 @@ do_gen_all_hostkeys(struct passwd *pw)
|
||||
if (stat(prv_file, &st) == 0) {
|
||||
if (st.st_size != 0)
|
||||
goto next;
|
||||
}
|
||||
else if (errno != ENOENT) {
|
||||
} else if (errno != ENOENT) {
|
||||
error("Could not stat %s: %s", key_types[i].path,
|
||||
strerror(errno));
|
||||
goto failnext;
|
||||
@ -1209,8 +1202,7 @@ known_hosts_find_delete(struct hostkey_foreach_line *l, void *_ctx)
|
||||
if (l->marker != MRK_NONE) {
|
||||
/* Don't remove CA and revocation lines */
|
||||
fprintf(ctx->out, "%s\n", l->line);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
/*
|
||||
* Hostname matches and has no CA/revoke
|
||||
* marker, delete it by *not* writing the
|
||||
@ -1222,8 +1214,7 @@ known_hosts_find_delete(struct hostkey_foreach_line *l, void *_ctx)
|
||||
ctx->host, l->linenum);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
else if (find_host) {
|
||||
} else if (find_host) {
|
||||
ctx->found_key = 1;
|
||||
if (!quiet) {
|
||||
printf("# Host %s found: line %lu %s\n",
|
||||
@ -1238,13 +1229,11 @@ known_hosts_find_delete(struct hostkey_foreach_line *l, void *_ctx)
|
||||
mprintf("%s %s %s %s\n", ctx->host,
|
||||
sshkey_type(l->key), fp, l->comment);
|
||||
free(fp);
|
||||
}
|
||||
else
|
||||
} else
|
||||
fprintf(ctx->out, "%s\n", l->line);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else if (delete_host) {
|
||||
} else if (delete_host) {
|
||||
/* Retain non-matching hosts when deleting */
|
||||
if (l->status == HKF_STATUS_INVALID) {
|
||||
ctx->invalid = 1;
|
||||
@ -1323,13 +1312,11 @@ do_known_hosts(struct passwd *pw, const char *name)
|
||||
unlink(tmp);
|
||||
}
|
||||
exit(1);
|
||||
}
|
||||
else if (delete_host && !ctx.found_key) {
|
||||
} else if (delete_host && !ctx.found_key) {
|
||||
logit("Host %s not found in %s", name, identity_file);
|
||||
if (inplace)
|
||||
unlink(tmp);
|
||||
}
|
||||
else if (inplace) {
|
||||
} else if (inplace) {
|
||||
/* Backup existing file */
|
||||
if (unlink(old) == -1 && errno != ENOENT)
|
||||
fatal("unlink %.100s: %s", old, strerror(errno));
|
||||
@ -1354,7 +1341,7 @@ do_known_hosts(struct passwd *pw, const char *name)
|
||||
}
|
||||
}
|
||||
|
||||
exit(find_host && !ctx.found_key);
|
||||
exit (find_host && !ctx.found_key);
|
||||
#endif /* !WINDOWS */
|
||||
}
|
||||
|
||||
@ -1390,8 +1377,7 @@ do_change_passphrase(struct passwd *pw)
|
||||
free(old_passphrase);
|
||||
if (r != 0)
|
||||
goto badkey;
|
||||
}
|
||||
else if (r != 0) {
|
||||
} else if (r != 0) {
|
||||
badkey:
|
||||
fatal("Failed to load key %s: %s", identity_file, ssh_err(r));
|
||||
}
|
||||
@ -1402,8 +1388,7 @@ do_change_passphrase(struct passwd *pw)
|
||||
if (identity_new_passphrase) {
|
||||
passphrase1 = xstrdup(identity_new_passphrase);
|
||||
passphrase2 = NULL;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
passphrase1 =
|
||||
read_passphrase("Enter new passphrase (empty for no "
|
||||
"passphrase): ", RP_ALLOW_STDIN);
|
||||
@ -1527,8 +1512,7 @@ do_change_comment(struct passwd *pw)
|
||||
|
||||
if (identity_comment) {
|
||||
strlcpy(new_comment, identity_comment, sizeof(new_comment));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
printf("Enter new comment: ");
|
||||
fflush(stdout);
|
||||
if (!fgets(new_comment, sizeof(new_comment), stdin)) {
|
||||
@ -1560,7 +1544,6 @@ do_change_comment(struct passwd *pw)
|
||||
fd = open(identity_file, O_WRONLY | O_CREAT | O_TRUNC, 0644);
|
||||
if (fd == -1)
|
||||
fatal("Could not save your public key in %s", identity_file);
|
||||
|
||||
#ifdef WINDOWS
|
||||
/* Windows POSIX adpater does not support fdopen() on open(file)*/
|
||||
close(fd);
|
||||
@ -1571,7 +1554,6 @@ do_change_comment(struct passwd *pw)
|
||||
if (f == NULL)
|
||||
fatal("fdopen %s failed: %s", identity_file, strerror(errno));
|
||||
#endif /* !WINDOWS */
|
||||
|
||||
if ((r = sshkey_write(public, f)) != 0)
|
||||
fatal("write key failed: %s", ssh_err(r));
|
||||
sshkey_free(public);
|
||||
@ -1716,8 +1698,7 @@ do_ca_sign(struct passwd *pw, int argc, char **argv)
|
||||
/* If a PKCS#11 token was specified then try to use it */
|
||||
if ((ca = load_pkcs11_key(tmp)) == NULL)
|
||||
fatal("No PKCS#11 key matching %s found", ca_key_path);
|
||||
}
|
||||
else if (prefer_agent) {
|
||||
} else if (prefer_agent) {
|
||||
/*
|
||||
* Agent signature requested. Try to use agent after making
|
||||
* sure the public key specified is actually present in the
|
||||
@ -1742,8 +1723,7 @@ do_ca_sign(struct passwd *pw, int argc, char **argv)
|
||||
fatal("CA key %s not found in agent", tmp);
|
||||
ssh_free_identitylist(agent_ids);
|
||||
ca->flags |= SSHKEY_FLAG_EXT;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
/* CA key is assumed to be a private key on the filesystem */
|
||||
ca = load_identity(tmp);
|
||||
}
|
||||
@ -1801,8 +1781,7 @@ do_ca_sign(struct passwd *pw, int argc, char **argv)
|
||||
key_type_name, agent_signer, &agent_fd)) != 0)
|
||||
fatal("Couldn't certify key %s via agent: %s",
|
||||
tmp, ssh_err(r));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if ((sshkey_certify(public, ca, key_type_name)) != 0)
|
||||
fatal("Couldn't certify key %s: %s",
|
||||
tmp, ssh_err(r));
|
||||
@ -1813,7 +1792,7 @@ do_ca_sign(struct passwd *pw, int argc, char **argv)
|
||||
xasprintf(&out, "%s-cert.pub", tmp);
|
||||
free(tmp);
|
||||
|
||||
if ((fd = open(out, O_WRONLY | O_CREAT | O_TRUNC, 0644)) == -1)
|
||||
if ((fd = open(out, O_WRONLY|O_CREAT|O_TRUNC, 0644)) == -1)
|
||||
fatal("Could not open \"%s\" for writing: %s", out,
|
||||
strerror(errno));
|
||||
#ifdef WINDOWS
|
||||
@ -1916,7 +1895,7 @@ parse_cert_times(char *timespec)
|
||||
* Backdate certificate one minute to avoid problems on hosts
|
||||
* with poorly-synchronised clocks.
|
||||
*/
|
||||
cert_valid_from = ((now - 59) / 60) * 60;
|
||||
cert_valid_from = ((now - 59)/ 60) * 60;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1985,8 +1964,7 @@ add_cert_option(char *opt)
|
||||
if (certflags_command != NULL)
|
||||
fatal("force-command already specified");
|
||||
certflags_command = xstrdup(val);
|
||||
}
|
||||
else if (strncasecmp(opt, "source-address=", 15) == 0) {
|
||||
} else if (strncasecmp(opt, "source-address=", 15) == 0) {
|
||||
val = opt + 15;
|
||||
if (*val == '\0')
|
||||
fatal("Empty source-address option");
|
||||
@ -1995,8 +1973,7 @@ add_cert_option(char *opt)
|
||||
if (addr_match_cidr_list(NULL, val) != 0)
|
||||
fatal("Invalid source-address list");
|
||||
certflags_src_addr = xstrdup(val);
|
||||
}
|
||||
else if (strncasecmp(opt, "extension:", 10) == 0 ||
|
||||
} else if (strncasecmp(opt, "extension:", 10) == 0 ||
|
||||
(iscrit = (strncasecmp(opt, "critical:", 9) == 0))) {
|
||||
val = xstrdup(strchr(opt, ':') + 1);
|
||||
if ((cp = strchr(val, '=')) != NULL)
|
||||
@ -2008,8 +1985,7 @@ add_cert_option(char *opt)
|
||||
NULL : xstrdup(cp);
|
||||
cert_userext[ncert_userext].crit = iscrit;
|
||||
ncert_userext++;
|
||||
}
|
||||
else
|
||||
} else
|
||||
fatal("Unsupported certificate option \"%s\"", opt);
|
||||
}
|
||||
|
||||
@ -2044,8 +2020,7 @@ show_options(struct sshbuf *optbuf, int in_critical)
|
||||
__func__, ssh_err(r));
|
||||
printf(" %s\n", arg);
|
||||
free(arg);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
printf(" UNKNOWN OPTION (len %zu)\n",
|
||||
sshbuf_len(option));
|
||||
sshbuf_reset(option);
|
||||
@ -2125,8 +2100,7 @@ do_show_cert(struct passwd *pw)
|
||||
f = stdin;
|
||||
path = "(stdin)";
|
||||
is_stdin = 1;
|
||||
}
|
||||
else if ((f = fopen(identity_file, "r")) == NULL)
|
||||
} else if ((f = fopen(identity_file, "r")) == NULL)
|
||||
fatal("fopen %s: %s", identity_file, strerror(errno));
|
||||
|
||||
while (read_keyfile_line(f, path, line, sizeof(line), &lnum) == 0) {
|
||||
@ -2195,8 +2169,7 @@ update_krl_from_file(struct passwd *pw, const char *file, int wild_ca,
|
||||
krl_spec = stdin;
|
||||
free(path);
|
||||
path = xstrdup("(standard input)");
|
||||
}
|
||||
else if ((krl_spec = fopen(path, "r")) == NULL)
|
||||
} else if ((krl_spec = fopen(path, "r")) == NULL)
|
||||
fatal("fopen %s: %s", path, strerror(errno));
|
||||
|
||||
if (!quiet)
|
||||
@ -2215,8 +2188,7 @@ update_krl_from_file(struct passwd *pw, const char *file, int wild_ca,
|
||||
/* Remember the start of a span of whitespace */
|
||||
if (r == -1)
|
||||
r = i;
|
||||
}
|
||||
else
|
||||
} else
|
||||
r = -1;
|
||||
}
|
||||
if (r != -1)
|
||||
@ -2260,8 +2232,7 @@ update_krl_from_file(struct passwd *pw, const char *file, int wild_ca,
|
||||
fatal("%s: revoke serial failed",
|
||||
__func__);
|
||||
}
|
||||
}
|
||||
else if (strncasecmp(cp, "id:", 3) == 0) {
|
||||
} else if (strncasecmp(cp, "id:", 3) == 0) {
|
||||
if (ca == NULL && !wild_ca) {
|
||||
fatal("revoking certificates by key ID "
|
||||
"requires specification of a CA key");
|
||||
@ -2270,19 +2241,16 @@ update_krl_from_file(struct passwd *pw, const char *file, int wild_ca,
|
||||
cp = cp + strspn(cp, " \t");
|
||||
if (ssh_krl_revoke_cert_by_key_id(krl, ca, cp) != 0)
|
||||
fatal("%s: revoke key ID failed", __func__);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (strncasecmp(cp, "key:", 4) == 0) {
|
||||
cp += 4;
|
||||
cp = cp + strspn(cp, " \t");
|
||||
was_explicit_key = 1;
|
||||
}
|
||||
else if (strncasecmp(cp, "sha1:", 5) == 0) {
|
||||
} else if (strncasecmp(cp, "sha1:", 5) == 0) {
|
||||
cp += 5;
|
||||
cp = cp + strspn(cp, " \t");
|
||||
was_sha1 = 1;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
/*
|
||||
* Just try to process the line as a key.
|
||||
* Parsing will fail if it isn't.
|
||||
@ -2358,7 +2326,7 @@ do_gen_krl(struct passwd *pw, int updating, int argc, char **argv)
|
||||
fatal("sshbuf_new failed");
|
||||
if (ssh_krl_to_blob(krl, kbuf, NULL, 0) != 0)
|
||||
fatal("Couldn't generate KRL");
|
||||
if ((fd = open(identity_file, O_WRONLY | O_CREAT | O_TRUNC, 0644)) == -1)
|
||||
if ((fd = open(identity_file, O_WRONLY|O_CREAT|O_TRUNC, 0644)) == -1)
|
||||
fatal("open %s: %s", identity_file, strerror(errno));
|
||||
if (atomicio(vwrite, fd, (void *)sshbuf_ptr(kbuf), sshbuf_len(kbuf)) !=
|
||||
sshbuf_len(kbuf))
|
||||
@ -2707,8 +2675,7 @@ main(int argc, char **argv)
|
||||
error("Too few arguments.");
|
||||
usage();
|
||||
}
|
||||
}
|
||||
else if (argc > 0 && !gen_krl && !check_krl) {
|
||||
} else if (argc > 0 && !gen_krl && !check_krl) {
|
||||
error("Too many arguments.");
|
||||
usage();
|
||||
}
|
||||
@ -2762,8 +2729,7 @@ main(int argc, char **argv)
|
||||
if (n == 0)
|
||||
fatal("%s: %s", identity_file, strerror(errno));
|
||||
exit(0);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
n += do_print_resource_record(pw,
|
||||
_PATH_HOST_RSA_KEY_FILE, rr_hostname);
|
||||
@ -2806,8 +2772,7 @@ main(int argc, char **argv)
|
||||
"file \"%s\": %s", identity_file,
|
||||
strerror(errno));
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
in = stdin;
|
||||
|
||||
if (out == NULL) {
|
||||
@ -2852,12 +2817,10 @@ main(int argc, char **argv)
|
||||
if (errno != ENOENT) {
|
||||
error("Could not stat %s: %s", dotsshdir,
|
||||
strerror(errno));
|
||||
}
|
||||
else if (mkdir(dotsshdir, 0700) < 0) {
|
||||
} else if (mkdir(dotsshdir, 0700) < 0) {
|
||||
error("Could not create directory '%s': %s",
|
||||
dotsshdir, strerror(errno));
|
||||
}
|
||||
else if (!quiet)
|
||||
} else if (!quiet)
|
||||
printf("Created directory '%s'.\n", dotsshdir);
|
||||
}
|
||||
}
|
||||
@ -2878,7 +2841,7 @@ main(int argc, char **argv)
|
||||
else if (identity_new_passphrase)
|
||||
passphrase1 = xstrdup(identity_new_passphrase);
|
||||
else {
|
||||
passphrase_again:
|
||||
passphrase_again:
|
||||
passphrase1 =
|
||||
read_passphrase("Enter passphrase (empty for no "
|
||||
"passphrase): ", RP_ALLOW_STDIN);
|
||||
@ -2903,8 +2866,7 @@ main(int argc, char **argv)
|
||||
|
||||
if (identity_comment) {
|
||||
strlcpy(comment, identity_comment, sizeof(comment));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
/* Create default comment field for the passphrase. */
|
||||
snprintf(comment, sizeof comment, "%s@%s", pw->pw_name, hostname);
|
||||
}
|
||||
@ -2929,7 +2891,7 @@ main(int argc, char **argv)
|
||||
printf("Your identification has been saved in %s.\n", identity_file);
|
||||
|
||||
strlcat(identity_file, ".pub", sizeof(identity_file));
|
||||
if ((fd = open(identity_file, O_WRONLY | O_CREAT | O_TRUNC, 0644)) == -1)
|
||||
if ((fd = open(identity_file, O_WRONLY|O_CREAT|O_TRUNC, 0644)) == -1)
|
||||
fatal("Unable to save public key to %s: %s",
|
||||
identity_file, strerror(errno));
|
||||
#ifdef WINDOWS
|
||||
|
Loading…
x
Reference in New Issue
Block a user