key.h revision 76259
11573Srgrimes/*	$OpenBSD: key.h,v 1.12 2001/04/17 10:53:24 markus Exp $	*/
21573Srgrimes
31573Srgrimes/*
41573Srgrimes * Copyright (c) 2000 Markus Friedl.  All rights reserved.
51573Srgrimes *
61573Srgrimes * Redistribution and use in source and binary forms, with or without
71573Srgrimes * modification, are permitted provided that the following conditions
81573Srgrimes * are met:
91573Srgrimes * 1. Redistributions of source code must retain the above copyright
101573Srgrimes *    notice, this list of conditions and the following disclaimer.
111573Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
121573Srgrimes *    notice, this list of conditions and the following disclaimer in the
131573Srgrimes *    documentation and/or other materials provided with the distribution.
141573Srgrimes *
151573Srgrimes * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
161573Srgrimes * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
171573Srgrimes * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
181573Srgrimes * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
191573Srgrimes * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
201573Srgrimes * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
211573Srgrimes * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
221573Srgrimes * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
231573Srgrimes * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
241573Srgrimes * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
251573Srgrimes */
261573Srgrimes#ifndef KEY_H
271573Srgrimes#define KEY_H
281573Srgrimes
291573Srgrimes#include <openssl/rsa.h>
301573Srgrimes#include <openssl/dsa.h>
311573Srgrimes
321573Srgrimestypedef struct Key Key;
331573Srgrimesenum types {
341573Srgrimes	KEY_RSA1,
351573Srgrimes	KEY_RSA,
361573Srgrimes	KEY_DSA,
371573Srgrimes	KEY_UNSPEC
381573Srgrimes};
391573Srgrimesenum fp_type {
401573Srgrimes	SSH_FP_SHA1,
411573Srgrimes	SSH_FP_MD5
421573Srgrimes};
431573Srgrimesenum fp_rep {
441573Srgrimes	SSH_FP_HEX,
451573Srgrimes	SSH_FP_BUBBLEBABBLE
461573Srgrimes};
471573Srgrimesstruct Key {
481573Srgrimes	int	type;
491573Srgrimes	RSA	*rsa;
501573Srgrimes	DSA	*dsa;
511573Srgrimes};
521573Srgrimes
531573SrgrimesKey	*key_new(int type);
541573SrgrimesKey	*key_new_private(int type);
551573Srgrimesvoid	key_free(Key *k);
561573Srgrimesint	key_equal(Key *a, Key *b);
571573Srgrimeschar	*key_fingerprint(Key *k, enum fp_type dgst_type, enum fp_rep dgst_rep);
581573Srgrimeschar	*key_type(Key *k);
591573Srgrimesint	key_write(Key *key, FILE *f);
601573Srgrimesint	key_read(Key *key, char **cpp);
618870Srgrimesu_int	key_size(Key *k);
621573Srgrimes
631573SrgrimesKey	*key_generate(int type, u_int bits);
641573SrgrimesKey	*key_from_private(Key *k);
651573Srgrimesint	key_type_from_name(char *name);
661573Srgrimes
671573SrgrimesKey	*key_from_blob(char *blob, int blen);
681573Srgrimesint	key_to_blob(Key *key, u_char **blobp, u_int *lenp);
691573Srgrimeschar	*key_ssh_name(Key *k);
701573Srgrimesint	key_names_valid2(const char *names);
711573Srgrimes
721573Srgrimesint
731573Srgrimeskey_sign(
741573Srgrimes    Key *key,
751573Srgrimes    u_char **sigp, int *lenp,
761573Srgrimes    u_char *data, int datalen);
771573Srgrimes
781573Srgrimesint
7919276Sachekey_verify(
8019276Sache    Key *key,
811573Srgrimes    u_char *signature, int signaturelen,
821573Srgrimes    u_char *data, int datalen);
831573Srgrimes
841573Srgrimes#endif
851573Srgrimes