xref: /titanic_41/usr/src/cmd/ssh/include/key.h (revision 2df1fe9ca32bb227b9158c67f5c00b54c20b10fd)
1 /*
2  * Copyright (c) 2000, 2001 Markus Friedl.  All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
14  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
15  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
16  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
17  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
18  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
19  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
20  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23  */
24 
25 #ifndef	_KEY_H
26 #define	_KEY_H
27 
28 /*	$OpenBSD: key.h,v 1.19 2002/03/18 17:23:31 markus Exp $	*/
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
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(const Key *, const Key *);
72 char	*key_fingerprint(Key *, enum fp_type, enum fp_rep);
73 char	*key_type(Key *);
74 int	 key_write(const 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(const Key *, u_char **, u_int *);
84 char	*key_ssh_name(const 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