Deleted Added
full compact
cipher.h (76262) cipher.h (92559)
1/* $OpenBSD: cipher.h,v 1.32 2002/03/04 17:27:39 stevesk Exp $ */
2/* $FreeBSD: head/crypto/openssh/cipher.h 92559 2002-03-18 10:09:43Z des $ */
3
1/*
2 * Author: Tatu Ylonen <ylo@cs.hut.fi>
3 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
4 * All rights reserved
5 *
6 * As far as I am concerned, the code I have written for this software
7 * can be used freely for any purpose. Any derived versions of this
8 * software must be clearly marked as such, and if the derived work is

--- 18 unchanged lines hidden (view full) ---

27 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
28 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34
4/*
5 * Author: Tatu Ylonen <ylo@cs.hut.fi>
6 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
7 * All rights reserved
8 *
9 * As far as I am concerned, the code I have written for this software
10 * can be used freely for any purpose. Any derived versions of this
11 * software must be clearly marked as such, and if the derived work is

--- 18 unchanged lines hidden (view full) ---

30 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
31 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
35 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 */
37
35/* RCSID("$OpenBSD: cipher.h,v 1.25 2000/12/19 23:17:56 markus Exp $"); */
36/* RCSID("$FreeBSD: head/crypto/openssh/cipher.h 76262 2001-05-04 04:14:23Z green $"); */
37
38#ifndef CIPHER_H
39#define CIPHER_H
40
38#ifndef CIPHER_H
39#define CIPHER_H
40
41#include <openssl/des.h>
42#include <openssl/blowfish.h>
43#include <openssl/rc4.h>
44#include <openssl/cast.h>
45#include "rijndael.h"
41#include <openssl/evp.h>
46/*
47 * Cipher types for SSH-1. New types can be added, but old types should not
48 * be removed for compatibility. The maximum allowed value is 31.
49 */
50#define SSH_CIPHER_SSH2 -3
51#define SSH_CIPHER_ILLEGAL -2 /* No valid cipher selected. */
52#define SSH_CIPHER_NOT_SET -1 /* None selected (invalid number). */
53#define SSH_CIPHER_NONE 0 /* no encryption */
54#define SSH_CIPHER_IDEA 1 /* IDEA CFB */
55#define SSH_CIPHER_DES 2 /* DES CBC */
56#define SSH_CIPHER_3DES 3 /* 3DES CBC */
57#define SSH_CIPHER_BROKEN_TSS 4 /* TRI's Simple Stream encryption CBC */
58#define SSH_CIPHER_BROKEN_RC4 5 /* Alleged RC4 */
59#define SSH_CIPHER_BLOWFISH 6
60#define SSH_CIPHER_RESERVED 7
61#define SSH_CIPHER_MAX 31
62
42/*
43 * Cipher types for SSH-1. New types can be added, but old types should not
44 * be removed for compatibility. The maximum allowed value is 31.
45 */
46#define SSH_CIPHER_SSH2 -3
47#define SSH_CIPHER_ILLEGAL -2 /* No valid cipher selected. */
48#define SSH_CIPHER_NOT_SET -1 /* None selected (invalid number). */
49#define SSH_CIPHER_NONE 0 /* no encryption */
50#define SSH_CIPHER_IDEA 1 /* IDEA CFB */
51#define SSH_CIPHER_DES 2 /* DES CBC */
52#define SSH_CIPHER_3DES 3 /* 3DES CBC */
53#define SSH_CIPHER_BROKEN_TSS 4 /* TRI's Simple Stream encryption CBC */
54#define SSH_CIPHER_BROKEN_RC4 5 /* Alleged RC4 */
55#define SSH_CIPHER_BLOWFISH 6
56#define SSH_CIPHER_RESERVED 7
57#define SSH_CIPHER_MAX 31
58
59#define CIPHER_ENCRYPT 1
60#define CIPHER_DECRYPT 0
61
63typedef struct Cipher Cipher;
64typedef struct CipherContext CipherContext;
65
62typedef struct Cipher Cipher;
63typedef struct CipherContext CipherContext;
64
65struct Cipher;
66struct CipherContext {
66struct CipherContext {
67 union {
68 struct {
69 des_key_schedule key;
70 des_cblock iv;
71 } des;
72 struct {
73 des_key_schedule key1;
74 des_key_schedule key2;
75 des_cblock iv2;
76 des_key_schedule key3;
77 des_cblock iv3;
78 } des3;
79 struct {
80 struct bf_key_st key;
81 u_char iv[8];
82 } bf;
83 struct {
84 CAST_KEY key;
85 u_char iv[8];
86 } cast;
87 struct {
88 u4byte iv[4];
89 rijndael_ctx enc;
90 rijndael_ctx dec;
91 } rijndael;
92 RC4_KEY rc4;
93 } u;
67 int plaintext;
68 EVP_CIPHER_CTX evp;
94 Cipher *cipher;
95};
69 Cipher *cipher;
70};
96struct Cipher {
97 char *name;
98 int number; /* for ssh1 only */
99 u_int block_size;
100 u_int key_len;
101 void (*setkey)(CipherContext *, const u_char *, u_int);
102 void (*setiv)(CipherContext *, const u_char *, u_int);
103 void (*encrypt)(CipherContext *, u_char *, const u_char *, u_int);
104 void (*decrypt)(CipherContext *, u_char *, const u_char *, u_int);
105};
106
71
107u_int cipher_mask_ssh1(int client);
108Cipher *cipher_by_name(const char *name);
109Cipher *cipher_by_number(int id);
110int cipher_number(const char *name);
111char *cipher_name(int id);
112int ciphers_valid(const char *names);
113void cipher_init(CipherContext *, Cipher *, const u_char *, u_int, const u_char *, u_int);
114void cipher_encrypt(CipherContext *context, u_char *dest, const u_char *src, u_int len);
115void cipher_decrypt(CipherContext *context, u_char *dest, const u_char *src, u_int len);
116void cipher_set_key_string(CipherContext *context, Cipher *cipher, const char *passphrase);
117
72u_int cipher_mask_ssh1(int);
73Cipher *cipher_by_name(const char *);
74Cipher *cipher_by_number(int);
75int cipher_number(const char *);
76char *cipher_name(int);
77int ciphers_valid(const char *);
78void cipher_init(CipherContext *, Cipher *, const u_char *, u_int,
79 const u_char *, u_int, int);
80void cipher_crypt(CipherContext *, u_char *, const u_char *, u_int);
81void cipher_cleanup(CipherContext *);
82void cipher_set_key_string(CipherContext *, Cipher *, const char *, int);
83u_int cipher_blocksize(Cipher *);
84u_int cipher_keylen(Cipher *);
118#endif /* CIPHER_H */
85#endif /* CIPHER_H */