key.h revision 92555
1137015Sdes/* $OpenBSD: key.h,v 1.18 2002/02/24 19:14:59 markus Exp $ */ 298937Sdes 398937Sdes/* 498937Sdes * Copyright (c) 2000, 2001 Markus Friedl. All rights reserved. 598937Sdes * 698937Sdes * Redistribution and use in source and binary forms, with or without 798937Sdes * modification, are permitted provided that the following conditions 898937Sdes * are met: 998937Sdes * 1. Redistributions of source code must retain the above copyright 1098937Sdes * notice, this list of conditions and the following disclaimer. 1198937Sdes * 2. Redistributions in binary form must reproduce the above copyright 1298937Sdes * notice, this list of conditions and the following disclaimer in the 1398937Sdes * documentation and/or other materials provided with the distribution. 1498937Sdes * 1598937Sdes * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 1698937Sdes * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 1798937Sdes * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 1898937Sdes * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 1998937Sdes * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 2098937Sdes * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2198937Sdes * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2298937Sdes * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2398937Sdes * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 2498937Sdes * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2598937Sdes */ 2698937Sdes#ifndef KEY_H 2798937Sdes#define KEY_H 2898937Sdes 2999060Sdes#include <openssl/rsa.h> 30113908Sdes#include <openssl/dsa.h> 3198937Sdes 3298937Sdestypedef struct Key Key; 3398937Sdesenum types { 3498937Sdes KEY_RSA1, 3598937Sdes KEY_RSA, 3698937Sdes KEY_DSA, 3798937Sdes KEY_UNSPEC 3898937Sdes}; 3998937Sdesenum fp_type { 4098937Sdes SSH_FP_SHA1, 4198937Sdes SSH_FP_MD5 4298937Sdes}; 4398937Sdesenum fp_rep { 4498937Sdes SSH_FP_HEX, 4598937Sdes SSH_FP_BUBBLEBABBLE 4698937Sdes}; 4798937Sdes 4898937Sdes/* key is stored in external hardware */ 49124208Sdes#define KEY_FLAG_EXT 0x0001 5098937Sdes 5198937Sdesstruct Key { 5298937Sdes int type; 53113908Sdes int flags; 5498937Sdes RSA *rsa; 5598937Sdes DSA *dsa; 5698937Sdes}; 5798937Sdes 5898937SdesKey *key_new(int); 5998937SdesKey *key_new_private(int); 6098937Sdesvoid key_free(Key *); 6198937Sdesint key_equal(Key *, Key *); 62113908Sdeschar *key_fingerprint(Key *, enum fp_type, enum fp_rep); 6398937Sdeschar *key_type(Key *); 64126274Sdesint key_write(Key *, FILE *); 65126274Sdesint key_read(Key *, char **); 66126274Sdesu_int key_size(Key *); 67126274Sdes 68126274SdesKey *key_generate(int, u_int); 69126274SdesKey *key_from_private(Key *); 70137015Sdesint key_type_from_name(char *); 71137015Sdes 72137015SdesKey *key_from_blob(u_char *, int); 73124208Sdesint key_to_blob(Key *, u_char **, u_int *); 7498937Sdeschar *key_ssh_name(Key *); 75113908Sdesint key_names_valid2(const char *); 76113908Sdes 7798937Sdesint key_sign(Key *, u_char **, u_int *, u_char *, u_int); 78113908Sdesint key_verify(Key *, u_char *, u_int, u_char *, u_int); 79137015Sdes 80113908Sdes#endif 81113908Sdes