Correct PPTP server firewall rules chain.
[tomato/davidwu.git] / release / src / router / dropbear / algo.h
blob955864bd57438068e0d65244f315a8d79ff03d51
1 /*
2 * Dropbear - a SSH2 server
3 *
4 * Copyright (c) 2002,2003 Matt Johnston
5 * All rights reserved.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal
9 * in the Software without restriction, including without limitation the rights
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 * SOFTWARE. */
25 #ifndef _ALGO_H_
27 #define _ALGO_H_
29 #include "includes.h"
30 #include "buffer.h"
32 #define DROPBEAR_MODE_UNUSED 0
33 #define DROPBEAR_MODE_CBC 1
34 #define DROPBEAR_MODE_CTR 2
36 struct Algo_Type {
38 const unsigned char *name; /* identifying name */
39 char val; /* a value for this cipher, or -1 for invalid */
40 const void *data; /* algorithm specific data */
41 char usable; /* whether we can use this algorithm */
42 const void *mode; /* the mode, currently only used for ciphers,
43 points to a 'struct dropbear_cipher_mode' */
46 typedef struct Algo_Type algo_type;
48 /* lists mapping ssh types of algorithms to internal values */
49 extern algo_type sshkex[];
50 extern algo_type sshhostkey[];
51 extern algo_type sshciphers[];
52 extern algo_type sshhashes[];
53 extern algo_type ssh_compress[];
54 extern algo_type ssh_nocompress[];
56 extern const struct dropbear_cipher dropbear_nocipher;
57 extern const struct dropbear_cipher_mode dropbear_mode_none;
58 extern const struct dropbear_hash dropbear_nohash;
60 struct dropbear_cipher {
61 const struct ltc_cipher_descriptor *cipherdesc;
62 const unsigned long keysize;
63 const unsigned char blocksize;
66 struct dropbear_cipher_mode {
67 int (*start)(int cipher, const unsigned char *IV,
68 const unsigned char *key,
69 int keylen, int num_rounds, void *cipher_state);
70 int (*encrypt)(const unsigned char *pt, unsigned char *ct,
71 unsigned long len, void *cipher_state);
72 int (*decrypt)(const unsigned char *ct, unsigned char *pt,
73 unsigned long len, void *cipher_state);
76 struct dropbear_hash {
77 const struct ltc_hash_descriptor *hash_desc;
78 const unsigned long keysize;
79 /* hashsize may be truncated from the size returned by hash_desc,
80 eg sha1-96 */
81 const unsigned char hashsize;
84 enum dropbear_kex_mode {
85 DROPBEAR_KEX_NORMAL_DH,
86 DROPBEAR_KEX_ECDH,
87 DROPBEAR_KEX_CURVE25519,
90 struct dropbear_kex {
91 enum dropbear_kex_mode mode;
93 /* "normal" DH KEX */
94 const unsigned char *dh_p_bytes;
95 const int dh_p_len;
97 /* elliptic curve DH KEX */
98 #ifdef DROPBEAR_ECDH
99 const struct dropbear_ecc_curve *ecc_curve;
100 #else
101 const void* dummy;
102 #endif
104 /* both */
105 const struct ltc_hash_descriptor *hash_desc;
108 int have_algo(char* algo, size_t algolen, algo_type algos[]);
109 void buf_put_algolist(buffer * buf, algo_type localalgos[]);
111 enum kexguess2_used {
112 KEXGUESS2_LOOK,
113 KEXGUESS2_NO,
114 KEXGUESS2_YES,
117 #define KEXGUESS2_ALGO_NAME "kexguess2@matt.ucc.asn.au"
118 #define KEXGUESS2_ALGO_ID 99
121 algo_type * buf_match_algo(buffer* buf, algo_type localalgos[],
122 enum kexguess2_used *kexguess2, int *goodguess);
124 #ifdef ENABLE_USER_ALGO_LIST
125 int check_user_algos(const char* user_algo_list, algo_type * algos,
126 const char *algo_desc);
127 char * algolist_string(algo_type algos[]);
128 #endif
130 enum {
131 DROPBEAR_COMP_NONE,
132 DROPBEAR_COMP_ZLIB,
133 DROPBEAR_COMP_ZLIB_DELAY,
136 #endif /* _ALGO_H_ */