xref: /minix3/lib/libtelnet/encrypt.h (revision 7348b5c52b47a1c199a1754a40bbfa360b536de2)
1*7348b5c5SDavid van Moolenbroek /*	$NetBSD: encrypt.h,v 1.9 2012/01/09 15:25:33 christos Exp $	*/
2*7348b5c5SDavid van Moolenbroek 
3*7348b5c5SDavid van Moolenbroek /*-
4*7348b5c5SDavid van Moolenbroek  * Copyright (c) 1991, 1993
5*7348b5c5SDavid van Moolenbroek  *	The Regents of the University of California.  All rights reserved.
6*7348b5c5SDavid van Moolenbroek  *
7*7348b5c5SDavid van Moolenbroek  * Redistribution and use in source and binary forms, with or without
8*7348b5c5SDavid van Moolenbroek  * modification, are permitted provided that the following conditions
9*7348b5c5SDavid van Moolenbroek  * are met:
10*7348b5c5SDavid van Moolenbroek  * 1. Redistributions of source code must retain the above copyright
11*7348b5c5SDavid van Moolenbroek  *    notice, this list of conditions and the following disclaimer.
12*7348b5c5SDavid van Moolenbroek  * 2. Redistributions in binary form must reproduce the above copyright
13*7348b5c5SDavid van Moolenbroek  *    notice, this list of conditions and the following disclaimer in the
14*7348b5c5SDavid van Moolenbroek  *    documentation and/or other materials provided with the distribution.
15*7348b5c5SDavid van Moolenbroek  * 3. Neither the name of the University nor the names of its contributors
16*7348b5c5SDavid van Moolenbroek  *    may be used to endorse or promote products derived from this software
17*7348b5c5SDavid van Moolenbroek  *    without specific prior written permission.
18*7348b5c5SDavid van Moolenbroek  *
19*7348b5c5SDavid van Moolenbroek  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20*7348b5c5SDavid van Moolenbroek  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21*7348b5c5SDavid van Moolenbroek  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22*7348b5c5SDavid van Moolenbroek  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23*7348b5c5SDavid van Moolenbroek  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24*7348b5c5SDavid van Moolenbroek  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25*7348b5c5SDavid van Moolenbroek  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26*7348b5c5SDavid van Moolenbroek  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27*7348b5c5SDavid van Moolenbroek  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28*7348b5c5SDavid van Moolenbroek  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29*7348b5c5SDavid van Moolenbroek  * SUCH DAMAGE.
30*7348b5c5SDavid van Moolenbroek  *
31*7348b5c5SDavid van Moolenbroek  *	from: @(#)encrypt.h	8.1 (Berkeley) 6/4/93
32*7348b5c5SDavid van Moolenbroek  */
33*7348b5c5SDavid van Moolenbroek 
34*7348b5c5SDavid van Moolenbroek /*
35*7348b5c5SDavid van Moolenbroek  * Copyright (C) 1990 by the Massachusetts Institute of Technology
36*7348b5c5SDavid van Moolenbroek  *
37*7348b5c5SDavid van Moolenbroek  * Export of this software from the United States of America is assumed
38*7348b5c5SDavid van Moolenbroek  * to require a specific license from the United States Government.
39*7348b5c5SDavid van Moolenbroek  * It is the responsibility of any person or organization contemplating
40*7348b5c5SDavid van Moolenbroek  * export to obtain such a license before exporting.
41*7348b5c5SDavid van Moolenbroek  *
42*7348b5c5SDavid van Moolenbroek  * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
43*7348b5c5SDavid van Moolenbroek  * distribute this software and its documentation for any purpose and
44*7348b5c5SDavid van Moolenbroek  * without fee is hereby granted, provided that the above copyright
45*7348b5c5SDavid van Moolenbroek  * notice appear in all copies and that both that copyright notice and
46*7348b5c5SDavid van Moolenbroek  * this permission notice appear in supporting documentation, and that
47*7348b5c5SDavid van Moolenbroek  * the name of M.I.T. not be used in advertising or publicity pertaining
48*7348b5c5SDavid van Moolenbroek  * to distribution of the software without specific, written prior
49*7348b5c5SDavid van Moolenbroek  * permission.  M.I.T. makes no representations about the suitability of
50*7348b5c5SDavid van Moolenbroek  * this software for any purpose.  It is provided "as is" without express
51*7348b5c5SDavid van Moolenbroek  * or implied warranty.
52*7348b5c5SDavid van Moolenbroek  */
53*7348b5c5SDavid van Moolenbroek 
54*7348b5c5SDavid van Moolenbroek #ifdef	ENCRYPTION
55*7348b5c5SDavid van Moolenbroek #include <sys/cdefs.h>
56*7348b5c5SDavid van Moolenbroek 
57*7348b5c5SDavid van Moolenbroek # ifndef __ENCRYPTION__
58*7348b5c5SDavid van Moolenbroek # define __ENCRYPTION__
59*7348b5c5SDavid van Moolenbroek 
60*7348b5c5SDavid van Moolenbroek #define	DIR_DECRYPT		1
61*7348b5c5SDavid van Moolenbroek #define	DIR_ENCRYPT		2
62*7348b5c5SDavid van Moolenbroek 
63*7348b5c5SDavid van Moolenbroek #define Block des_cblock
64*7348b5c5SDavid van Moolenbroek typedef unsigned char *BlockT;
65*7348b5c5SDavid van Moolenbroek #define Schedule des_key_schedule
66*7348b5c5SDavid van Moolenbroek 
67*7348b5c5SDavid van Moolenbroek #define	VALIDKEY(key)	( key[0] | key[1] | key[2] | key[3] | \
68*7348b5c5SDavid van Moolenbroek 			  key[4] | key[5] | key[6] | key[7])
69*7348b5c5SDavid van Moolenbroek 
70*7348b5c5SDavid van Moolenbroek #define	SAMEKEY(k1, k2)	(!bcmp((void *)k1, (void *)k2, sizeof(Block)))
71*7348b5c5SDavid van Moolenbroek 
72*7348b5c5SDavid van Moolenbroek typedef	struct {
73*7348b5c5SDavid van Moolenbroek 	short		type;
74*7348b5c5SDavid van Moolenbroek 	int		length;
75*7348b5c5SDavid van Moolenbroek 	unsigned char	*data;
76*7348b5c5SDavid van Moolenbroek } Session_Key;
77*7348b5c5SDavid van Moolenbroek 
78*7348b5c5SDavid van Moolenbroek 
79*7348b5c5SDavid van Moolenbroek typedef struct {
80*7348b5c5SDavid van Moolenbroek 	const char	*name;
81*7348b5c5SDavid van Moolenbroek 	int	type;
82*7348b5c5SDavid van Moolenbroek 	void	(*output)(unsigned char *, int);
83*7348b5c5SDavid van Moolenbroek 	int	(*input)(int);
84*7348b5c5SDavid van Moolenbroek 	void	(*init)(int);
85*7348b5c5SDavid van Moolenbroek 	int	(*start)(int, int);
86*7348b5c5SDavid van Moolenbroek 	int	(*is)(unsigned char *, int);
87*7348b5c5SDavid van Moolenbroek 	int	(*reply)(unsigned char *, int);
88*7348b5c5SDavid van Moolenbroek 	void	(*session)(Session_Key *, int);
89*7348b5c5SDavid van Moolenbroek 	int	(*keyid)(int, unsigned char *, int *);
90*7348b5c5SDavid van Moolenbroek 	void	(*printsub)(unsigned char *, int, unsigned char *, int);
91*7348b5c5SDavid van Moolenbroek } Encryptions;
92*7348b5c5SDavid van Moolenbroek 
93*7348b5c5SDavid van Moolenbroek #define	SK_DES		1	/* Matched Kerberos v5 KEYTYPE_DES */
94*7348b5c5SDavid van Moolenbroek 
95*7348b5c5SDavid van Moolenbroek #include "enc-proto.h"
96*7348b5c5SDavid van Moolenbroek 
97*7348b5c5SDavid van Moolenbroek extern int encrypt_debug_mode;
98*7348b5c5SDavid van Moolenbroek extern int (*decrypt_input)(int);
99*7348b5c5SDavid van Moolenbroek extern void (*encrypt_output)(unsigned char *, int);
100*7348b5c5SDavid van Moolenbroek # endif /* __ENCRYPTION__ */
101*7348b5c5SDavid van Moolenbroek #endif /* ENCRYPTION */
102