Mercurial > dropbear
comparison keyimport.c @ 1913:38c6fd7d7a82
Fix dropbearconvert ecdsa parsing error typo
Simplify handling for different key types
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Tue, 29 Mar 2022 23:55:35 +0800 |
parents | 8b4274d34fe8 |
children | f978a15194ba |
comparison
equal
deleted
inserted
replaced
1912:8b4274d34fe8 | 1913:38c6fd7d7a82 |
---|---|
599 /* discard checkkey1 */ | 599 /* discard checkkey1 */ |
600 buf_getint(blobbuf); | 600 buf_getint(blobbuf); |
601 /* discard checkkey2 */ | 601 /* discard checkkey2 */ |
602 buf_getint(blobbuf); | 602 buf_getint(blobbuf); |
603 | 603 |
604 if (type != DROPBEAR_SIGNKEY_NONE) { | 604 errmsg = "Unsupported OpenSSH key type"; |
605 retkey->type = type; | 605 retkey->type = type; |
606 ret = DROPBEAR_FAILURE; | |
607 /* Parse private key part */ | |
606 #if DROPBEAR_RSA | 608 #if DROPBEAR_RSA |
607 if (type == DROPBEAR_SIGNKEY_RSA) { | 609 if (type == DROPBEAR_SIGNKEY_RSA) { |
608 if (buf_get_rsa_priv_ossh(blobbuf, retkey) | 610 errmsg = "Error parsing OpenSSH RSA key"; |
609 == DROPBEAR_SUCCESS) { | 611 ret = buf_get_rsa_priv_ossh(blobbuf, retkey); |
610 errmsg = NULL; | 612 } |
611 retval = retkey; | |
612 goto error; | |
613 } else { | |
614 errmsg = "Error parsing OpenSSH RSA key"; | |
615 goto ossh_error; | |
616 } | |
617 } | |
618 #endif | 613 #endif |
619 #if DROPBEAR_ED25519 | 614 #if DROPBEAR_ED25519 |
620 if (type == DROPBEAR_SIGNKEY_ED25519) { | 615 if (type == DROPBEAR_SIGNKEY_ED25519) { |
621 if (buf_get_ed25519_priv_ossh(blobbuf, retkey) | 616 errmsg = "Error parsing OpenSSH ed25519 key"; |
622 == DROPBEAR_SUCCESS) { | 617 ret = buf_get_ed25519_priv_ossh(blobbuf, retkey); |
623 errmsg = NULL; | 618 } |
624 retval = retkey; | |
625 goto error; | |
626 } else { | |
627 errmsg = "Error parsing OpenSSH ed25519 key"; | |
628 goto ossh_error; | |
629 } | |
630 } | |
631 #endif | 619 #endif |
632 #if DROPBEAR_ECDSA | 620 #if DROPBEAR_ECDSA |
633 if (signkey_is_ecdsa(type)) { | 621 if (signkey_is_ecdsa(type)) { |
634 if (buf_get_ecdsa_priv_ossh(blobbuf, retkey) | 622 errmsg = "Error parsing OpenSSH ecdsa key"; |
635 == DROPBEAR_SUCCESS) { | 623 ret = buf_get_ecdsa_priv_ossh(blobbuf, retkey); |
636 errmsg = NULL; | 624 } |
637 retval = retkey; | |
638 goto error; | |
639 } else { | |
640 errmsg = "Error parsing OpenSSH ed25519 key"; | |
641 goto ossh_error; | |
642 } | |
643 } | |
644 #endif | 625 #endif |
645 } | 626 if (ret == DROPBEAR_SUCCESS) { |
646 | 627 errmsg = NULL; |
647 errmsg = "Unsupported OpenSSH key type"; | 628 retval = retkey; |
648 ossh_error: | 629 goto error; |
630 } | |
631 | |
632 ossh_error: | |
649 sign_key_free(retkey); | 633 sign_key_free(retkey); |
650 retkey = NULL; | 634 retkey = NULL; |
651 goto error; | 635 goto error; |
652 } | 636 } |
653 | 637 |