key.h revision 126274
1126274Sdes/*	$OpenBSD: key.h,v 1.23 2003/11/10 16:23:41 jakob Exp $	*/
276259Sgreen
365668Skris/*
492555Sdes * Copyright (c) 2000, 2001 Markus Friedl.  All rights reserved.
565668Skris *
665668Skris * Redistribution and use in source and binary forms, with or without
765668Skris * modification, are permitted provided that the following conditions
865668Skris * are met:
965668Skris * 1. Redistributions of source code must retain the above copyright
1065668Skris *    notice, this list of conditions and the following disclaimer.
1165668Skris * 2. Redistributions in binary form must reproduce the above copyright
1265668Skris *    notice, this list of conditions and the following disclaimer in the
1365668Skris *    documentation and/or other materials provided with the distribution.
1465668Skris *
1565668Skris * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
1665668Skris * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
1765668Skris * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
1865668Skris * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
1965668Skris * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
2065668Skris * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2165668Skris * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2265668Skris * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2365668Skris * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
2465668Skris * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2565668Skris */
2658582Skris#ifndef KEY_H
2758582Skris#define KEY_H
2858582Skris
2976259Sgreen#include <openssl/rsa.h>
3076259Sgreen#include <openssl/dsa.h>
3176259Sgreen
3258582Skristypedef struct Key Key;
3358582Skrisenum types {
3476259Sgreen	KEY_RSA1,
3558582Skris	KEY_RSA,
3658582Skris	KEY_DSA,
3776259Sgreen	KEY_UNSPEC
3858582Skris};
3976259Sgreenenum fp_type {
4076259Sgreen	SSH_FP_SHA1,
4176259Sgreen	SSH_FP_MD5
4276259Sgreen};
4376259Sgreenenum fp_rep {
4476259Sgreen	SSH_FP_HEX,
4576259Sgreen	SSH_FP_BUBBLEBABBLE
4676259Sgreen};
4792555Sdes
4892555Sdes/* key is stored in external hardware */
4992555Sdes#define KEY_FLAG_EXT		0x0001
5092555Sdes
5158582Skrisstruct Key {
5292555Sdes	int	 type;
5392555Sdes	int	 flags;
5458582Skris	RSA	*rsa;
5558582Skris	DSA	*dsa;
5658582Skris};
5758582Skris
58126274SdesKey		*key_new(int);
59126274SdesKey		*key_new_private(int);
60126274Sdesvoid		 key_free(Key *);
61126274SdesKey		*key_demote(const Key *);
62126274Sdesint		 key_equal(const Key *, const Key *);
63126274Sdeschar		*key_fingerprint(const Key *, enum fp_type, enum fp_rep);
64126274Sdesu_char		*key_fingerprint_raw(const Key *, enum fp_type, u_int *);
65126274Sdesconst char	*key_type(const Key *);
66126274Sdesint		 key_write(const Key *, FILE *);
67126274Sdesint		 key_read(Key *, char **);
68126274Sdesu_int		 key_size(const Key *);
6958582Skris
7092555SdesKey	*key_generate(int, u_int);
71126274SdesKey	*key_from_private(const Key *);
7292555Sdesint	 key_type_from_name(char *);
7376259Sgreen
74126274SdesKey		*key_from_blob(const u_char *, u_int);
75126274Sdesint		 key_to_blob(const Key *, u_char **, u_int *);
76126274Sdesconst char	*key_ssh_name(const Key *);
77126274Sdesint		 key_names_valid2(const char *);
7876259Sgreen
79126274Sdesint	 key_sign(const Key *, u_char **, u_int *, const u_char *, u_int);
80126274Sdesint	 key_verify(const Key *, const u_char *, u_int, const u_char *, u_int);
8176259Sgreen
82126274Sdesint	 ssh_dss_sign(const Key *, u_char **, u_int *, const u_char *, u_int);
83126274Sdesint	 ssh_dss_verify(const Key *, const u_char *, u_int, const u_char *, u_int);
84126274Sdesint	 ssh_rsa_sign(const Key *, u_char **, u_int *, const u_char *, u_int);
85126274Sdesint	 ssh_rsa_verify(const Key *, const u_char *, u_int, const u_char *, u_int);
86113908Sdes
8758582Skris#endif
88