key.h revision 113908
1113908Sdes/* $OpenBSD: key.h,v 1.20 2003/02/12 09:33:04 markus 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 5892555SdesKey *key_new(int); 5992555SdesKey *key_new_private(int); 6092555Sdesvoid key_free(Key *); 6198675SdesKey *key_demote(Key *); 6292555Sdesint key_equal(Key *, Key *); 6392555Sdeschar *key_fingerprint(Key *, enum fp_type, enum fp_rep); 6492555Sdeschar *key_type(Key *); 6592555Sdesint key_write(Key *, FILE *); 6692555Sdesint key_read(Key *, char **); 6792555Sdesu_int key_size(Key *); 6858582Skris 6992555SdesKey *key_generate(int, u_int); 7092555SdesKey *key_from_private(Key *); 7192555Sdesint key_type_from_name(char *); 7276259Sgreen 7392555SdesKey *key_from_blob(u_char *, int); 7492555Sdesint key_to_blob(Key *, u_char **, u_int *); 7592555Sdeschar *key_ssh_name(Key *); 7692555Sdesint key_names_valid2(const char *); 7776259Sgreen 7892555Sdesint key_sign(Key *, u_char **, u_int *, u_char *, u_int); 7992555Sdesint key_verify(Key *, u_char *, u_int, u_char *, u_int); 8076259Sgreen 81113908Sdesint ssh_dss_sign(Key *, u_char **, u_int *, u_char *, u_int); 82113908Sdesint ssh_dss_verify(Key *, u_char *, u_int, u_char *, u_int); 83113908Sdesint ssh_rsa_sign(Key *, u_char **, u_int *, u_char *, u_int); 84113908Sdesint ssh_rsa_verify(Key *, u_char *, u_int, u_char *, u_int); 85113908Sdes 8658582Skris#endif 87