xref: /titanic_50/usr/src/cmd/ssh/include/cipher.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*	$OpenBSD: cipher.h,v 1.33 2002/03/18 17:13:15 markus Exp $	*/
2*7c478bd9Sstevel@tonic-gate 
3*7c478bd9Sstevel@tonic-gate #ifndef	_CIPHER_H
4*7c478bd9Sstevel@tonic-gate #define	_CIPHER_H
5*7c478bd9Sstevel@tonic-gate 
6*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
7*7c478bd9Sstevel@tonic-gate 
8*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus
9*7c478bd9Sstevel@tonic-gate extern "C" {
10*7c478bd9Sstevel@tonic-gate #endif
11*7c478bd9Sstevel@tonic-gate 
12*7c478bd9Sstevel@tonic-gate 
13*7c478bd9Sstevel@tonic-gate /*
14*7c478bd9Sstevel@tonic-gate  * Author: Tatu Ylonen <ylo@cs.hut.fi>
15*7c478bd9Sstevel@tonic-gate  * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
16*7c478bd9Sstevel@tonic-gate  *                    All rights reserved
17*7c478bd9Sstevel@tonic-gate  *
18*7c478bd9Sstevel@tonic-gate  * As far as I am concerned, the code I have written for this software
19*7c478bd9Sstevel@tonic-gate  * can be used freely for any purpose.  Any derived versions of this
20*7c478bd9Sstevel@tonic-gate  * software must be clearly marked as such, and if the derived work is
21*7c478bd9Sstevel@tonic-gate  * incompatible with the protocol description in the RFC file, it must be
22*7c478bd9Sstevel@tonic-gate  * called by a name other than "ssh" or "Secure Shell".
23*7c478bd9Sstevel@tonic-gate  *
24*7c478bd9Sstevel@tonic-gate  * Copyright (c) 2000 Markus Friedl.  All rights reserved.
25*7c478bd9Sstevel@tonic-gate  *
26*7c478bd9Sstevel@tonic-gate  * Redistribution and use in source and binary forms, with or without
27*7c478bd9Sstevel@tonic-gate  * modification, are permitted provided that the following conditions
28*7c478bd9Sstevel@tonic-gate  * are met:
29*7c478bd9Sstevel@tonic-gate  * 1. Redistributions of source code must retain the above copyright
30*7c478bd9Sstevel@tonic-gate  *    notice, this list of conditions and the following disclaimer.
31*7c478bd9Sstevel@tonic-gate  * 2. Redistributions in binary form must reproduce the above copyright
32*7c478bd9Sstevel@tonic-gate  *    notice, this list of conditions and the following disclaimer in the
33*7c478bd9Sstevel@tonic-gate  *    documentation and/or other materials provided with the distribution.
34*7c478bd9Sstevel@tonic-gate  *
35*7c478bd9Sstevel@tonic-gate  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
36*7c478bd9Sstevel@tonic-gate  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
37*7c478bd9Sstevel@tonic-gate  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
38*7c478bd9Sstevel@tonic-gate  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
39*7c478bd9Sstevel@tonic-gate  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
40*7c478bd9Sstevel@tonic-gate  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
41*7c478bd9Sstevel@tonic-gate  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
42*7c478bd9Sstevel@tonic-gate  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
43*7c478bd9Sstevel@tonic-gate  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
44*7c478bd9Sstevel@tonic-gate  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
45*7c478bd9Sstevel@tonic-gate  */
46*7c478bd9Sstevel@tonic-gate 
47*7c478bd9Sstevel@tonic-gate #include <openssl/evp.h>
48*7c478bd9Sstevel@tonic-gate /*
49*7c478bd9Sstevel@tonic-gate  * Cipher types for SSH-1.  New types can be added, but old types should not
50*7c478bd9Sstevel@tonic-gate  * be removed for compatibility.  The maximum allowed value is 31.
51*7c478bd9Sstevel@tonic-gate  */
52*7c478bd9Sstevel@tonic-gate #define SSH_CIPHER_SSH2		-3
53*7c478bd9Sstevel@tonic-gate #define SSH_CIPHER_ILLEGAL	-2	/* No valid cipher selected. */
54*7c478bd9Sstevel@tonic-gate #define SSH_CIPHER_NOT_SET	-1	/* None selected (invalid number). */
55*7c478bd9Sstevel@tonic-gate #define SSH_CIPHER_NONE		0	/* no encryption */
56*7c478bd9Sstevel@tonic-gate #define SSH_CIPHER_IDEA		1	/* IDEA CFB */
57*7c478bd9Sstevel@tonic-gate #define SSH_CIPHER_DES		2	/* DES CBC */
58*7c478bd9Sstevel@tonic-gate #define SSH_CIPHER_3DES		3	/* 3DES CBC */
59*7c478bd9Sstevel@tonic-gate #define SSH_CIPHER_BROKEN_TSS	4	/* TRI's Simple Stream encryption CBC */
60*7c478bd9Sstevel@tonic-gate #define SSH_CIPHER_BROKEN_RC4	5	/* Alleged RC4 */
61*7c478bd9Sstevel@tonic-gate #define SSH_CIPHER_BLOWFISH	6
62*7c478bd9Sstevel@tonic-gate #define SSH_CIPHER_RESERVED	7
63*7c478bd9Sstevel@tonic-gate #define SSH_CIPHER_MAX		31
64*7c478bd9Sstevel@tonic-gate 
65*7c478bd9Sstevel@tonic-gate #define CIPHER_ENCRYPT		1
66*7c478bd9Sstevel@tonic-gate #define CIPHER_DECRYPT		0
67*7c478bd9Sstevel@tonic-gate 
68*7c478bd9Sstevel@tonic-gate typedef struct Cipher Cipher;
69*7c478bd9Sstevel@tonic-gate typedef struct CipherContext CipherContext;
70*7c478bd9Sstevel@tonic-gate 
71*7c478bd9Sstevel@tonic-gate struct Cipher;
72*7c478bd9Sstevel@tonic-gate struct CipherContext {
73*7c478bd9Sstevel@tonic-gate 	int	plaintext;
74*7c478bd9Sstevel@tonic-gate 	EVP_CIPHER_CTX evp;
75*7c478bd9Sstevel@tonic-gate 	Cipher *cipher;
76*7c478bd9Sstevel@tonic-gate };
77*7c478bd9Sstevel@tonic-gate 
78*7c478bd9Sstevel@tonic-gate u_int	 cipher_mask_ssh1(int);
79*7c478bd9Sstevel@tonic-gate Cipher	*cipher_by_name(const char *);
80*7c478bd9Sstevel@tonic-gate Cipher	*cipher_by_number(int);
81*7c478bd9Sstevel@tonic-gate int	 cipher_number(const char *);
82*7c478bd9Sstevel@tonic-gate char	*cipher_name(int);
83*7c478bd9Sstevel@tonic-gate int	 ciphers_valid(const char *);
84*7c478bd9Sstevel@tonic-gate void	 cipher_init(CipherContext *, Cipher *, const u_char *, u_int,
85*7c478bd9Sstevel@tonic-gate     const u_char *, u_int, int);
86*7c478bd9Sstevel@tonic-gate void	 cipher_crypt(CipherContext *, u_char *, const u_char *, u_int);
87*7c478bd9Sstevel@tonic-gate void	 cipher_cleanup(CipherContext *);
88*7c478bd9Sstevel@tonic-gate void	 cipher_set_key_string(CipherContext *, Cipher *, const char *, int);
89*7c478bd9Sstevel@tonic-gate u_int	 cipher_blocksize(Cipher *);
90*7c478bd9Sstevel@tonic-gate u_int	 cipher_keylen(Cipher *);
91*7c478bd9Sstevel@tonic-gate 
92*7c478bd9Sstevel@tonic-gate u_int	 cipher_get_number(Cipher *);
93*7c478bd9Sstevel@tonic-gate void	 cipher_get_keyiv(CipherContext *, u_char *, u_int);
94*7c478bd9Sstevel@tonic-gate void	 cipher_set_keyiv(CipherContext *, u_char *);
95*7c478bd9Sstevel@tonic-gate int	 cipher_get_keyiv_len(CipherContext *);
96*7c478bd9Sstevel@tonic-gate int	 cipher_get_keycontext(CipherContext *, u_char *);
97*7c478bd9Sstevel@tonic-gate void	 cipher_set_keycontext(CipherContext *, u_char *);
98*7c478bd9Sstevel@tonic-gate 
99*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus
100*7c478bd9Sstevel@tonic-gate }
101*7c478bd9Sstevel@tonic-gate #endif
102*7c478bd9Sstevel@tonic-gate 
103*7c478bd9Sstevel@tonic-gate #endif /* _CIPHER_H */
104