Allow IPv6 address entry in tools>ping - Loosens valid character check
[tomato/davidwu.git] / release / src / router / dropbear / algo.h
blob87e524dfc1f09dea5bad51f1ba265cfef69f179d
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 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 unsigned long keysize;
63 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 *hashdesc;
78 unsigned long keysize;
79 unsigned char hashsize;
82 void crypto_init();
83 int have_algo(char* algo, size_t algolen, algo_type algos[]);
84 void buf_put_algolist(buffer * buf, algo_type localalgos[]);
86 algo_type * svr_buf_match_algo(buffer* buf, algo_type localalgos[],
87 int *goodguess);
88 algo_type * cli_buf_match_algo(buffer* buf, algo_type localalgos[],
89 int *goodguess);
91 #endif /* _ALGO_H_ */