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