xref: /titanic_44/usr/src/cmd/ssh/include/key.h (revision 40e5e17b3361b3eea56a9723071c406894a20b78)
1 /*	$OpenBSD: key.h,v 1.19 2002/03/18 17:23:31 markus Exp $	*/
2 
3 #ifndef	_KEY_H
4 #define	_KEY_H
5 
6 #pragma ident	"%Z%%M%	%I%	%E% SMI"
7 
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11 
12 
13 /*
14  * Copyright (c) 2000, 2001 Markus Friedl.  All rights reserved.
15  *
16  * Redistribution and use in source and binary forms, with or without
17  * modification, are permitted provided that the following conditions
18  * are met:
19  * 1. Redistributions of source code must retain the above copyright
20  *    notice, this list of conditions and the following disclaimer.
21  * 2. Redistributions in binary form must reproduce the above copyright
22  *    notice, this list of conditions and the following disclaimer in the
23  *    documentation and/or other materials provided with the distribution.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
26  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
27  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
28  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
29  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
30  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
31  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
32  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
34  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35  */
36 
37 #include <openssl/rsa.h>
38 #include <openssl/dsa.h>
39 
40 typedef struct Key Key;
41 enum types {
42 	KEY_RSA1,
43 	KEY_RSA,
44 	KEY_DSA,
45 	KEY_NULL,
46 	KEY_UNSPEC
47 };
48 enum fp_type {
49 	SSH_FP_SHA1,
50 	SSH_FP_MD5
51 };
52 enum fp_rep {
53 	SSH_FP_HEX,
54 	SSH_FP_BUBBLEBABBLE
55 };
56 
57 /* key is stored in external hardware */
58 #define KEY_FLAG_EXT		0x0001
59 
60 struct Key {
61 	int	 type;
62 	int	 flags;
63 	RSA	*rsa;
64 	DSA	*dsa;
65 };
66 
67 Key	*key_new(int);
68 Key	*key_new_private(int);
69 void	 key_free(Key *);
70 Key	*key_demote(Key *);
71 int	 key_equal(Key *, Key *);
72 char	*key_fingerprint(Key *, enum fp_type, enum fp_rep);
73 char	*key_type(Key *);
74 int	 key_write(Key *, FILE *);
75 int	 key_read(Key *, char **);
76 u_int	 key_size(Key *);
77 
78 Key	*key_generate(int, u_int);
79 Key	*key_from_private(Key *);
80 int	 key_type_from_name(char *);
81 
82 Key	*key_from_blob(u_char *, int);
83 int	 key_to_blob(Key *, u_char **, u_int *);
84 char	*key_ssh_name(Key *);
85 int	 key_names_valid2(const char *);
86 
87 int	 key_sign(Key *, u_char **, u_int *, u_char *, u_int);
88 int	 key_verify(Key *, u_char *, u_int, u_char *, u_int);
89 
90 #ifdef __cplusplus
91 }
92 #endif
93 
94 #endif /* _KEY_H */
95