summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Lindstrom <mouring@eviladmin.org>2002-03-22 01:45:53 +0000
committerBen Lindstrom <mouring@eviladmin.org>2002-03-22 01:45:53 +0000
commita674e8df809e0b746cd6ae0490709aad3850bbb8 (patch)
treeea7a50ca34248870e18b3e3ebfab290121b1bf18
parentf6027d3407f8665cc64321bcee8786311a58fa0c (diff)
- markus@cvs.openbsd.org 2002/03/18 17:23:31
[key.c key.h] add key_demote() for ssh-privsep
-rw-r--r--ChangeLog5
-rw-r--r--key.c45
-rw-r--r--key.h3
3 files changed, 50 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 87b6d1266..fade46942 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -50,6 +50,9 @@
50 - markus@cvs.openbsd.org 2002/03/18 17:16:38 50 - markus@cvs.openbsd.org 2002/03/18 17:16:38
51 [packet.c packet.h] 51 [packet.c packet.h]
52 export/import cipher state, iv and ssh2 seqnr; needed by ssh-privsep 52 export/import cipher state, iv and ssh2 seqnr; needed by ssh-privsep
53 - markus@cvs.openbsd.org 2002/03/18 17:23:31
54 [key.c key.h]
55 add key_demote() for ssh-privsep
53 56
5420020317 5720020317
55 - (tim) [configure.ac] Assume path given with --with-pid-dir=PATH is wanted, 58 - (tim) [configure.ac] Assume path given with --with-pid-dir=PATH is wanted,
@@ -7896,4 +7899,4 @@
7896 - Wrote replacements for strlcpy and mkdtemp 7899 - Wrote replacements for strlcpy and mkdtemp
7897 - Released 1.0pre1 7900 - Released 1.0pre1
7898 7901
7899$Id: ChangeLog,v 1.1939 2002/03/22 01:42:04 mouring Exp $ 7902$Id: ChangeLog,v 1.1940 2002/03/22 01:45:53 mouring Exp $
diff --git a/key.c b/key.c
index cda91571a..51902ea25 100644
--- a/key.c
+++ b/key.c
@@ -32,7 +32,7 @@
32 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */ 33 */
34#include "includes.h" 34#include "includes.h"
35RCSID("$OpenBSD: key.c,v 1.41 2002/02/28 15:46:33 markus Exp $"); 35RCSID("$OpenBSD: key.c,v 1.42 2002/03/18 17:23:31 markus Exp $");
36 36
37#include <openssl/evp.h> 37#include <openssl/evp.h>
38 38
@@ -801,3 +801,46 @@ 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}
diff --git a/key.h b/key.h
index a2257731a..8d1fa4126 100644
--- a/key.h
+++ b/key.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: key.h,v 1.18 2002/02/24 19:14:59 markus Exp $ */ 1/* $OpenBSD: key.h,v 1.19 2002/03/18 17:23:31 markus Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2000, 2001 Markus Friedl. All rights reserved. 4 * Copyright (c) 2000, 2001 Markus Friedl. All rights reserved.
@@ -58,6 +58,7 @@ struct Key {
58Key *key_new(int); 58Key *key_new(int);
59Key *key_new_private(int); 59Key *key_new_private(int);
60void key_free(Key *); 60void key_free(Key *);
61Key *key_demote(Key *);
61int key_equal(Key *, Key *); 62int key_equal(Key *, Key *);
62char *key_fingerprint(Key *, enum fp_type, enum fp_rep); 63char *key_fingerprint(Key *, enum fp_type, enum fp_rep);
63char *key_type(Key *); 64char *key_type(Key *);