xref: /titanic_50/usr/src/cmd/ssh/include/key.h (revision 442d23f49355a5d0694c758975be57af39f91a61)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * Copyright (c) 2000, 2001 Markus Friedl.  All rights reserved.
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * Redistribution and use in source and binary forms, with or without
57c478bd9Sstevel@tonic-gate  * modification, are permitted provided that the following conditions
67c478bd9Sstevel@tonic-gate  * are met:
77c478bd9Sstevel@tonic-gate  * 1. Redistributions of source code must retain the above copyright
87c478bd9Sstevel@tonic-gate  *    notice, this list of conditions and the following disclaimer.
97c478bd9Sstevel@tonic-gate  * 2. Redistributions in binary form must reproduce the above copyright
107c478bd9Sstevel@tonic-gate  *    notice, this list of conditions and the following disclaimer in the
117c478bd9Sstevel@tonic-gate  *    documentation and/or other materials provided with the distribution.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
147c478bd9Sstevel@tonic-gate  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
157c478bd9Sstevel@tonic-gate  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
167c478bd9Sstevel@tonic-gate  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
177c478bd9Sstevel@tonic-gate  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
187c478bd9Sstevel@tonic-gate  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
197c478bd9Sstevel@tonic-gate  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
207c478bd9Sstevel@tonic-gate  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
217c478bd9Sstevel@tonic-gate  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
227c478bd9Sstevel@tonic-gate  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
237c478bd9Sstevel@tonic-gate  */
247c478bd9Sstevel@tonic-gate 
25*442d23f4Sjp161948 #ifndef	_KEY_H
26*442d23f4Sjp161948 #define	_KEY_H
27*442d23f4Sjp161948 
28*442d23f4Sjp161948 /*	$OpenBSD: key.h,v 1.19 2002/03/18 17:23:31 markus Exp $	*/
29*442d23f4Sjp161948 
30*442d23f4Sjp161948 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*442d23f4Sjp161948 
32*442d23f4Sjp161948 #ifdef __cplusplus
33*442d23f4Sjp161948 extern "C" {
34*442d23f4Sjp161948 #endif
35*442d23f4Sjp161948 
36*442d23f4Sjp161948 
377c478bd9Sstevel@tonic-gate #include <openssl/rsa.h>
387c478bd9Sstevel@tonic-gate #include <openssl/dsa.h>
397c478bd9Sstevel@tonic-gate 
407c478bd9Sstevel@tonic-gate typedef struct Key Key;
417c478bd9Sstevel@tonic-gate enum types {
427c478bd9Sstevel@tonic-gate 	KEY_RSA1,
437c478bd9Sstevel@tonic-gate 	KEY_RSA,
447c478bd9Sstevel@tonic-gate 	KEY_DSA,
457c478bd9Sstevel@tonic-gate 	KEY_NULL,
467c478bd9Sstevel@tonic-gate 	KEY_UNSPEC
477c478bd9Sstevel@tonic-gate };
487c478bd9Sstevel@tonic-gate enum fp_type {
497c478bd9Sstevel@tonic-gate 	SSH_FP_SHA1,
507c478bd9Sstevel@tonic-gate 	SSH_FP_MD5
517c478bd9Sstevel@tonic-gate };
527c478bd9Sstevel@tonic-gate enum fp_rep {
537c478bd9Sstevel@tonic-gate 	SSH_FP_HEX,
547c478bd9Sstevel@tonic-gate 	SSH_FP_BUBBLEBABBLE
557c478bd9Sstevel@tonic-gate };
567c478bd9Sstevel@tonic-gate 
577c478bd9Sstevel@tonic-gate /* key is stored in external hardware */
587c478bd9Sstevel@tonic-gate #define KEY_FLAG_EXT		0x0001
597c478bd9Sstevel@tonic-gate 
607c478bd9Sstevel@tonic-gate struct Key {
617c478bd9Sstevel@tonic-gate 	int	 type;
627c478bd9Sstevel@tonic-gate 	int	 flags;
637c478bd9Sstevel@tonic-gate 	RSA	*rsa;
647c478bd9Sstevel@tonic-gate 	DSA	*dsa;
657c478bd9Sstevel@tonic-gate };
667c478bd9Sstevel@tonic-gate 
677c478bd9Sstevel@tonic-gate Key	*key_new(int);
687c478bd9Sstevel@tonic-gate Key	*key_new_private(int);
697c478bd9Sstevel@tonic-gate void	 key_free(Key *);
707c478bd9Sstevel@tonic-gate Key	*key_demote(Key *);
71*442d23f4Sjp161948 int	 key_equal(const Key *, const Key *);
727c478bd9Sstevel@tonic-gate char	*key_fingerprint(Key *, enum fp_type, enum fp_rep);
737c478bd9Sstevel@tonic-gate char	*key_type(Key *);
74*442d23f4Sjp161948 int	 key_write(const Key *, FILE *);
757c478bd9Sstevel@tonic-gate int	 key_read(Key *, char **);
767c478bd9Sstevel@tonic-gate u_int	 key_size(Key *);
777c478bd9Sstevel@tonic-gate 
787c478bd9Sstevel@tonic-gate Key	*key_generate(int, u_int);
797c478bd9Sstevel@tonic-gate Key	*key_from_private(Key *);
807c478bd9Sstevel@tonic-gate int	 key_type_from_name(char *);
817c478bd9Sstevel@tonic-gate 
827c478bd9Sstevel@tonic-gate Key	*key_from_blob(u_char *, int);
83*442d23f4Sjp161948 int	 key_to_blob(const Key *, u_char **, u_int *);
84*442d23f4Sjp161948 char	*key_ssh_name(const Key *);
857c478bd9Sstevel@tonic-gate int	 key_names_valid2(const char *);
867c478bd9Sstevel@tonic-gate 
877c478bd9Sstevel@tonic-gate int	 key_sign(Key *, u_char **, u_int *, u_char *, u_int);
887c478bd9Sstevel@tonic-gate int	 key_verify(Key *, u_char *, u_int, u_char *, u_int);
897c478bd9Sstevel@tonic-gate 
907c478bd9Sstevel@tonic-gate #ifdef __cplusplus
917c478bd9Sstevel@tonic-gate }
927c478bd9Sstevel@tonic-gate #endif
937c478bd9Sstevel@tonic-gate 
947c478bd9Sstevel@tonic-gate #endif /* _KEY_H */
95