dropbear: update to 2015.67
[tomato.git] / release / src-rt-6.x.4708 / router / dropbear / algo.h
blob1758c51cebd411f0df35b7abdf8ede0c80a9f605
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_delaycompress[];
55 extern algo_type ssh_nocompress[];
57 extern const struct dropbear_cipher dropbear_nocipher;
58 extern const struct dropbear_cipher_mode dropbear_mode_none;
59 extern const struct dropbear_hash dropbear_nohash;
61 struct dropbear_cipher {
62 const struct ltc_cipher_descriptor *cipherdesc;
63 const unsigned long keysize;
64 const unsigned char blocksize;
67 struct dropbear_cipher_mode {
68 int (*start)(int cipher, const unsigned char *IV,
69 const unsigned char *key,
70 int keylen, int num_rounds, void *cipher_state);
71 int (*encrypt)(const unsigned char *pt, unsigned char *ct,
72 unsigned long len, void *cipher_state);
73 int (*decrypt)(const unsigned char *ct, unsigned char *pt,
74 unsigned long len, void *cipher_state);
77 struct dropbear_hash {
78 const struct ltc_hash_descriptor *hash_desc;
79 const unsigned long keysize;
80 /* hashsize may be truncated from the size returned by hash_desc,
81 eg sha1-96 */
82 const unsigned char hashsize;
85 enum dropbear_kex_mode {
86 DROPBEAR_KEX_NORMAL_DH,
87 DROPBEAR_KEX_ECDH,
88 DROPBEAR_KEX_CURVE25519,
91 struct dropbear_kex {
92 enum dropbear_kex_mode mode;
94 /* "normal" DH KEX */
95 const unsigned char *dh_p_bytes;
96 const int dh_p_len;
98 /* elliptic curve DH KEX */
99 #ifdef DROPBEAR_ECDH
100 const struct dropbear_ecc_curve *ecc_curve;
101 #else
102 const void* dummy;
103 #endif
105 /* both */
106 const struct ltc_hash_descriptor *hash_desc;
109 int have_algo(char* algo, size_t algolen, algo_type algos[]);
110 void buf_put_algolist(buffer * buf, algo_type localalgos[]);
112 enum kexguess2_used {
113 KEXGUESS2_LOOK,
114 KEXGUESS2_NO,
115 KEXGUESS2_YES,
118 #define KEXGUESS2_ALGO_NAME "kexguess2@matt.ucc.asn.au"
119 #define KEXGUESS2_ALGO_ID 99
122 algo_type * buf_match_algo(buffer* buf, algo_type localalgos[],
123 enum kexguess2_used *kexguess2, int *goodguess);
125 #ifdef ENABLE_USER_ALGO_LIST
126 int check_user_algos(const char* user_algo_list, algo_type * algos,
127 const char *algo_desc);
128 char * algolist_string(algo_type algos[]);
129 #endif
131 enum {
132 DROPBEAR_COMP_NONE,
133 DROPBEAR_COMP_ZLIB,
134 DROPBEAR_COMP_ZLIB_DELAY,
137 #endif /* _ALGO_H_ */