summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Johnston <matt@ucc.asn.au>2022-03-29 23:55:35 +0800
committerMatt Johnston <matt@ucc.asn.au>2022-03-29 23:55:35 +0800
commit0229ff53b0e88ec36c68ce701cc6b4ffe11c67a9 (patch)
tree44f56613ff948c4ad4bf880ee85a1ce81f1a3903
parentc3d0ebb0bd6e0c3d2dfb7f4d99df362b55e6838c (diff)
downloaddropbear-0229ff53b0e88ec36c68ce701cc6b4ffe11c67a9.tar.gz
Fix dropbearconvert ecdsa parsing error typo
Simplify handling for different key types
-rw-r--r--keyimport.c58
1 files changed, 21 insertions, 37 deletions
diff --git a/keyimport.c b/keyimport.c
index 31d06e2..01344aa 100644
--- a/keyimport.c
+++ b/keyimport.c
@@ -601,51 +601,35 @@ static sign_key *openssh_read(const char *filename, const char * UNUSED(passphra
/* discard checkkey2 */
buf_getint(blobbuf);
- if (type != DROPBEAR_SIGNKEY_NONE) {
- retkey->type = type;
+ errmsg = "Unsupported OpenSSH key type";
+ retkey->type = type;
+ ret = DROPBEAR_FAILURE;
+ /* Parse private key part */
#if DROPBEAR_RSA
- if (type == DROPBEAR_SIGNKEY_RSA) {
- if (buf_get_rsa_priv_ossh(blobbuf, retkey)
- == DROPBEAR_SUCCESS) {
- errmsg = NULL;
- retval = retkey;
- goto error;
- } else {
- errmsg = "Error parsing OpenSSH RSA key";
- goto ossh_error;
- }
- }
+ if (type == DROPBEAR_SIGNKEY_RSA) {
+ errmsg = "Error parsing OpenSSH RSA key";
+ ret = buf_get_rsa_priv_ossh(blobbuf, retkey);
+ }
#endif
#if DROPBEAR_ED25519
- if (type == DROPBEAR_SIGNKEY_ED25519) {
- if (buf_get_ed25519_priv_ossh(blobbuf, retkey)
- == DROPBEAR_SUCCESS) {
- errmsg = NULL;
- retval = retkey;
- goto error;
- } else {
- errmsg = "Error parsing OpenSSH ed25519 key";
- goto ossh_error;
- }
- }
+ if (type == DROPBEAR_SIGNKEY_ED25519) {
+ errmsg = "Error parsing OpenSSH ed25519 key";
+ ret = buf_get_ed25519_priv_ossh(blobbuf, retkey);
+ }
#endif
#if DROPBEAR_ECDSA
- if (signkey_is_ecdsa(type)) {
- if (buf_get_ecdsa_priv_ossh(blobbuf, retkey)
- == DROPBEAR_SUCCESS) {
- errmsg = NULL;
- retval = retkey;
- goto error;
- } else {
- errmsg = "Error parsing OpenSSH ed25519 key";
- goto ossh_error;
- }
- }
+ if (signkey_is_ecdsa(type)) {
+ errmsg = "Error parsing OpenSSH ecdsa key";
+ ret = buf_get_ecdsa_priv_ossh(blobbuf, retkey);
+ }
#endif
+ if (ret == DROPBEAR_SUCCESS) {
+ errmsg = NULL;
+ retval = retkey;
+ goto error;
}
- errmsg = "Unsupported OpenSSH key type";
- ossh_error:
+ossh_error:
sign_key_free(retkey);
retkey = NULL;
goto error;