summaryrefslogtreecommitdiff
path: root/key.c
diff options
context:
space:
mode:
Diffstat (limited to 'key.c')
-rw-r--r--key.c43
1 files changed, 0 insertions, 43 deletions
diff --git a/key.c b/key.c
index fb6bff95b..cda91571a 100644
--- a/key.c
+++ b/key.c
@@ -801,46 +801,3 @@ key_verify(
801 break; 801 break;
802 } 802 }
803} 803}
804
805/* Converts a private to a public key */
806
807Key *
808key_demote(Key *k)
809{
810 Key *pk;
811
812 pk = xmalloc(sizeof(*pk));
813 pk->type = k->type;
814 pk->flags = k->flags;
815 pk->dsa = NULL;
816 pk->rsa = NULL;
817
818 switch (k->type) {
819 case KEY_RSA1:
820 case KEY_RSA:
821 if ((pk->rsa = RSA_new()) == NULL)
822 fatal("key_demote: RSA_new failed");
823 if ((pk->rsa->e = BN_dup(k->rsa->e)) == NULL)
824 fatal("key_demote: BN_dup failed");
825 if ((pk->rsa->n = BN_dup(k->rsa->n)) == NULL)
826 fatal("key_demote: BN_dup failed");
827 break;
828 case KEY_DSA:
829 if ((pk->dsa = DSA_new()) == NULL)
830 fatal("key_demote: DSA_new failed");
831 if ((pk->dsa->p = BN_dup(k->dsa->p)) == NULL)
832 fatal("key_demote: BN_dup failed");
833 if ((pk->dsa->q = BN_dup(k->dsa->q)) == NULL)
834 fatal("key_demote: BN_dup failed");
835 if ((pk->dsa->g = BN_dup(k->dsa->g)) == NULL)
836 fatal("key_demote: BN_dup failed");
837 if ((pk->dsa->pub_key = BN_dup(k->dsa->pub_key)) == NULL)
838 fatal("key_demote: BN_dup failed");
839 break;
840 default:
841 fatal("key_free: bad key type %d", k->type);
842 break;
843 }
844
845 return (pk);
846}