diff --git a/src/keys.c b/src/keys.c index 35d4950..798fbae 100644 --- a/src/keys.c +++ b/src/keys.c @@ -428,30 +428,19 @@ static int parse_pub_text(const char *text, size_t n, const char *label, return 0; } -int scr_pub_load(const char *path, struct scr_pub *out) -{ - struct buf b = scr_read_file(path, 4 * 1024 * 1024); - int rc; - - if (is_private_blob(&b, 8192)) { - scr_die(SCR_EUSAGE, - "%s is a private key; pass the recipient's public key " - "(usually %s.pub)", path, path); - } - rc = parse_pub_text((const char *)b.data, b.len, path, out); - free(b.data); - return rc; -} - int scr_pub_load_any(const char *path, struct scr_pub *out) { struct buf b = scr_read_file(path, 4 * 1024 * 1024); int priv; priv = is_private_blob(&b, 8192); + if (!priv) { + int rc = parse_pub_text((const char *)b.data, b.len, path, out); + + free(b.data); + return rc; + } free(b.data); - if (!priv) - return scr_pub_load(path, out); { struct scr_priv k; diff --git a/src/main.c b/src/main.c index 61f9776..70107ba 100644 --- a/src/main.c +++ b/src/main.c @@ -48,7 +48,7 @@ static const char *need_arg(int argc, char **argv, int *i, const char *opt) int main(int argc, char **argv) { - int encrypt = 1, decrypt = 0, fingerprint = 0, binary = 0, quiet = 0; + int decrypt = 0, fingerprint = 0, binary = 0, quiet = 0; const char *recipient = NULL, *key = NULL, *input = NULL, *output = NULL; int i; @@ -71,11 +71,9 @@ int main(int argc, char **argv) return 0; } if (strcmp(a, "-e") == 0 || strcmp(a, "--encrypt") == 0) { - encrypt = 1; decrypt = 0; } else if (strcmp(a, "-d") == 0 || strcmp(a, "--decrypt") == 0) { decrypt = 1; - encrypt = 0; } else if (strcmp(a, "-r") == 0 || strcmp(a, "--recipient") == 0) { recipient = need_arg(argc, argv, &i, a); } else if (strncmp(a, "--recipient=", 12) == 0) { @@ -193,7 +191,6 @@ int main(int argc, char **argv) return rc; } - (void)encrypt; { struct scr_pub to; struct buf in, env; diff --git a/src/sshcrypt.h b/src/sshcrypt.h index 15194f2..19d9c0c 100644 --- a/src/sshcrypt.h +++ b/src/sshcrypt.h @@ -61,7 +61,6 @@ struct scr_priv { char fingerprint[64]; }; -int scr_pub_load(const char *path, struct scr_pub *out); int scr_pub_load_any(const char *path, struct scr_pub *out); void scr_pub_free(struct scr_pub *k); int scr_priv_load(const char *path, struct scr_priv *out);