10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * Copyright (c) 2000, 2001 Markus Friedl. All rights reserved. 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * Redistribution and use in source and binary forms, with or without 50Sstevel@tonic-gate * modification, are permitted provided that the following conditions 60Sstevel@tonic-gate * are met: 70Sstevel@tonic-gate * 1. Redistributions of source code must retain the above copyright 80Sstevel@tonic-gate * notice, this list of conditions and the following disclaimer. 90Sstevel@tonic-gate * 2. Redistributions in binary form must reproduce the above copyright 100Sstevel@tonic-gate * notice, this list of conditions and the following disclaimer in the 110Sstevel@tonic-gate * documentation and/or other materials provided with the distribution. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 140Sstevel@tonic-gate * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 150Sstevel@tonic-gate * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 160Sstevel@tonic-gate * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 170Sstevel@tonic-gate * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 180Sstevel@tonic-gate * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 190Sstevel@tonic-gate * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 200Sstevel@tonic-gate * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 210Sstevel@tonic-gate * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 220Sstevel@tonic-gate * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 230Sstevel@tonic-gate */ 240Sstevel@tonic-gate 25*5243Sjp161948 #ifndef _KEY_H 26*5243Sjp161948 #define _KEY_H 27*5243Sjp161948 28*5243Sjp161948 /* $OpenBSD: key.h,v 1.19 2002/03/18 17:23:31 markus Exp $ */ 29*5243Sjp161948 30*5243Sjp161948 #pragma ident "%Z%%M% %I% %E% SMI" 31*5243Sjp161948 32*5243Sjp161948 #ifdef __cplusplus 33*5243Sjp161948 extern "C" { 34*5243Sjp161948 #endif 35*5243Sjp161948 36*5243Sjp161948 370Sstevel@tonic-gate #include <openssl/rsa.h> 380Sstevel@tonic-gate #include <openssl/dsa.h> 390Sstevel@tonic-gate 400Sstevel@tonic-gate typedef struct Key Key; 410Sstevel@tonic-gate enum types { 420Sstevel@tonic-gate KEY_RSA1, 430Sstevel@tonic-gate KEY_RSA, 440Sstevel@tonic-gate KEY_DSA, 450Sstevel@tonic-gate KEY_NULL, 460Sstevel@tonic-gate KEY_UNSPEC 470Sstevel@tonic-gate }; 480Sstevel@tonic-gate enum fp_type { 490Sstevel@tonic-gate SSH_FP_SHA1, 500Sstevel@tonic-gate SSH_FP_MD5 510Sstevel@tonic-gate }; 520Sstevel@tonic-gate enum fp_rep { 530Sstevel@tonic-gate SSH_FP_HEX, 540Sstevel@tonic-gate SSH_FP_BUBBLEBABBLE 550Sstevel@tonic-gate }; 560Sstevel@tonic-gate 570Sstevel@tonic-gate /* key is stored in external hardware */ 580Sstevel@tonic-gate #define KEY_FLAG_EXT 0x0001 590Sstevel@tonic-gate 600Sstevel@tonic-gate struct Key { 610Sstevel@tonic-gate int type; 620Sstevel@tonic-gate int flags; 630Sstevel@tonic-gate RSA *rsa; 640Sstevel@tonic-gate DSA *dsa; 650Sstevel@tonic-gate }; 660Sstevel@tonic-gate 670Sstevel@tonic-gate Key *key_new(int); 680Sstevel@tonic-gate Key *key_new_private(int); 690Sstevel@tonic-gate void key_free(Key *); 700Sstevel@tonic-gate Key *key_demote(Key *); 71*5243Sjp161948 int key_equal(const Key *, const Key *); 720Sstevel@tonic-gate char *key_fingerprint(Key *, enum fp_type, enum fp_rep); 730Sstevel@tonic-gate char *key_type(Key *); 74*5243Sjp161948 int key_write(const Key *, FILE *); 750Sstevel@tonic-gate int key_read(Key *, char **); 760Sstevel@tonic-gate u_int key_size(Key *); 770Sstevel@tonic-gate 780Sstevel@tonic-gate Key *key_generate(int, u_int); 790Sstevel@tonic-gate Key *key_from_private(Key *); 800Sstevel@tonic-gate int key_type_from_name(char *); 810Sstevel@tonic-gate 820Sstevel@tonic-gate Key *key_from_blob(u_char *, int); 83*5243Sjp161948 int key_to_blob(const Key *, u_char **, u_int *); 84*5243Sjp161948 char *key_ssh_name(const Key *); 850Sstevel@tonic-gate int key_names_valid2(const char *); 860Sstevel@tonic-gate 870Sstevel@tonic-gate int key_sign(Key *, u_char **, u_int *, u_char *, u_int); 880Sstevel@tonic-gate int key_verify(Key *, u_char *, u_int, u_char *, u_int); 890Sstevel@tonic-gate 900Sstevel@tonic-gate #ifdef __cplusplus 910Sstevel@tonic-gate } 920Sstevel@tonic-gate #endif 930Sstevel@tonic-gate 940Sstevel@tonic-gate #endif /* _KEY_H */ 95