annotate common-algo.c @ 1348:5c2899e35b63 fuzz

fuzz harness
author Matt Johnston <matt@ucc.asn.au>
date Sat, 13 May 2017 22:50:54 +0800
parents eed9376a4ad6
children 2c9dac2d6707
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1 /*
74
e3adf4cf5465 License boilerplate etc, add Mihnea as an author to some of the files
Matt Johnston <matt@ucc.asn.au>
parents: 4
diff changeset
2 * Dropbear SSH
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3 *
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4 * Copyright (c) 2002,2003 Matt Johnston
74
e3adf4cf5465 License boilerplate etc, add Mihnea as an author to some of the files
Matt Johnston <matt@ucc.asn.au>
parents: 4
diff changeset
5 * Copyright (c) 2004 by Mihnea Stoenescu
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6 * All rights reserved.
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7 *
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8 * Permission is hereby granted, free of charge, to any person obtaining a copy
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
9 * of this software and associated documentation files (the "Software"), to deal
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
10 * in the Software without restriction, including without limitation the rights
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
12 * copies of the Software, and to permit persons to whom the Software is
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
13 * furnished to do so, subject to the following conditions:
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
14 *
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
15 * The above copyright notice and this permission notice shall be included in
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
16 * all copies or substantial portions of the Software.
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
17 *
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
24 * SOFTWARE. */
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
25
761
ac2158e3e403 ecc kind of works, needs fixing/testing
Matt Johnston <matt@ucc.asn.au>
parents: 759
diff changeset
26 #include "includes.h"
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
27 #include "algo.h"
741
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
28 #include "session.h"
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
29 #include "dbutil.h"
1224
82e2037d34ea Move dh group constants to a separate file
Matt Johnston <matt@ucc.asn.au>
parents: 1204
diff changeset
30 #include "dh_groups.h"
761
ac2158e3e403 ecc kind of works, needs fixing/testing
Matt Johnston <matt@ucc.asn.au>
parents: 759
diff changeset
31 #include "ltc_prng.h"
ac2158e3e403 ecc kind of works, needs fixing/testing
Matt Johnston <matt@ucc.asn.au>
parents: 759
diff changeset
32 #include "ecc.h"
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
33
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
34 /* This file (algo.c) organises the ciphers which can be used, and is used to
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
35 * decide which ciphers/hashes/compression/signing to use during key exchange*/
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
36
502
43bbe17d6ba0 - Add Counter Mode support
Matt Johnston <matt@ucc.asn.au>
parents: 501
diff changeset
37 static int void_cipher(const unsigned char* in, unsigned char* out,
761
ac2158e3e403 ecc kind of works, needs fixing/testing
Matt Johnston <matt@ucc.asn.au>
parents: 759
diff changeset
38 unsigned long len, void* UNUSED(cipher_state)) {
543
e12c9225acbd - Don't memcpy() in place with void_encrypt
Matt Johnston <matt@ucc.asn.au>
parents: 503
diff changeset
39 if (in != out) {
e12c9225acbd - Don't memcpy() in place with void_encrypt
Matt Johnston <matt@ucc.asn.au>
parents: 503
diff changeset
40 memmove(out, in, len);
e12c9225acbd - Don't memcpy() in place with void_encrypt
Matt Johnston <matt@ucc.asn.au>
parents: 503
diff changeset
41 }
502
43bbe17d6ba0 - Add Counter Mode support
Matt Johnston <matt@ucc.asn.au>
parents: 501
diff changeset
42 return CRYPT_OK;
43bbe17d6ba0 - Add Counter Mode support
Matt Johnston <matt@ucc.asn.au>
parents: 501
diff changeset
43 }
43bbe17d6ba0 - Add Counter Mode support
Matt Johnston <matt@ucc.asn.au>
parents: 501
diff changeset
44
761
ac2158e3e403 ecc kind of works, needs fixing/testing
Matt Johnston <matt@ucc.asn.au>
parents: 759
diff changeset
45 static int void_start(int UNUSED(cipher), const unsigned char* UNUSED(IV),
ac2158e3e403 ecc kind of works, needs fixing/testing
Matt Johnston <matt@ucc.asn.au>
parents: 759
diff changeset
46 const unsigned char* UNUSED(key),
ac2158e3e403 ecc kind of works, needs fixing/testing
Matt Johnston <matt@ucc.asn.au>
parents: 759
diff changeset
47 int UNUSED(keylen), int UNUSED(num_rounds), void* UNUSED(cipher_state)) {
502
43bbe17d6ba0 - Add Counter Mode support
Matt Johnston <matt@ucc.asn.au>
parents: 501
diff changeset
48 return CRYPT_OK;
43bbe17d6ba0 - Add Counter Mode support
Matt Johnston <matt@ucc.asn.au>
parents: 501
diff changeset
49 }
43bbe17d6ba0 - Add Counter Mode support
Matt Johnston <matt@ucc.asn.au>
parents: 501
diff changeset
50
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
51 /* Mappings for ciphers, parameters are
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
52 {&cipher_desc, keysize, blocksize} */
715
cd3d3c63d189 Make hmac-sha2-256 and hmac-sha2-512 work
Matt Johnston <matt@ucc.asn.au>
parents: 686
diff changeset
53
cd3d3c63d189 Make hmac-sha2-256 and hmac-sha2-512 work
Matt Johnston <matt@ucc.asn.au>
parents: 686
diff changeset
54 /* Remember to add new ciphers/hashes to regciphers/reghashes too */
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
55
502
43bbe17d6ba0 - Add Counter Mode support
Matt Johnston <matt@ucc.asn.au>
parents: 501
diff changeset
56 #ifdef DROPBEAR_AES256
228
5e4110bb753a - Fixed twofish algorithm naming so it actually works.
Matt Johnston <matt@ucc.asn.au>
parents: 227
diff changeset
57 static const struct dropbear_cipher dropbear_aes256 =
5e4110bb753a - Fixed twofish algorithm naming so it actually works.
Matt Johnston <matt@ucc.asn.au>
parents: 227
diff changeset
58 {&aes_desc, 32, 16};
5e4110bb753a - Fixed twofish algorithm naming so it actually works.
Matt Johnston <matt@ucc.asn.au>
parents: 227
diff changeset
59 #endif
502
43bbe17d6ba0 - Add Counter Mode support
Matt Johnston <matt@ucc.asn.au>
parents: 501
diff changeset
60 #ifdef DROPBEAR_AES128
227
ad1b24e39bf3 Make a variables static
Matt Johnston <matt@ucc.asn.au>
parents: 194
diff changeset
61 static const struct dropbear_cipher dropbear_aes128 =
150
82fcf3185616 Cleaning out various dead wood found with -dead_strip
Matt Johnston <matt@ucc.asn.au>
parents: 74
diff changeset
62 {&aes_desc, 16, 16};
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
63 #endif
502
43bbe17d6ba0 - Add Counter Mode support
Matt Johnston <matt@ucc.asn.au>
parents: 501
diff changeset
64 #ifdef DROPBEAR_BLOWFISH
227
ad1b24e39bf3 Make a variables static
Matt Johnston <matt@ucc.asn.au>
parents: 194
diff changeset
65 static const struct dropbear_cipher dropbear_blowfish =
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
66 {&blowfish_desc, 16, 8};
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
67 #endif
502
43bbe17d6ba0 - Add Counter Mode support
Matt Johnston <matt@ucc.asn.au>
parents: 501
diff changeset
68 #ifdef DROPBEAR_TWOFISH256
228
5e4110bb753a - Fixed twofish algorithm naming so it actually works.
Matt Johnston <matt@ucc.asn.au>
parents: 227
diff changeset
69 static const struct dropbear_cipher dropbear_twofish256 =
5e4110bb753a - Fixed twofish algorithm naming so it actually works.
Matt Johnston <matt@ucc.asn.au>
parents: 227
diff changeset
70 {&twofish_desc, 32, 16};
5e4110bb753a - Fixed twofish algorithm naming so it actually works.
Matt Johnston <matt@ucc.asn.au>
parents: 227
diff changeset
71 #endif
502
43bbe17d6ba0 - Add Counter Mode support
Matt Johnston <matt@ucc.asn.au>
parents: 501
diff changeset
72 #ifdef DROPBEAR_TWOFISH128
227
ad1b24e39bf3 Make a variables static
Matt Johnston <matt@ucc.asn.au>
parents: 194
diff changeset
73 static const struct dropbear_cipher dropbear_twofish128 =
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
74 {&twofish_desc, 16, 16};
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
75 #endif
502
43bbe17d6ba0 - Add Counter Mode support
Matt Johnston <matt@ucc.asn.au>
parents: 501
diff changeset
76 #ifdef DROPBEAR_3DES
227
ad1b24e39bf3 Make a variables static
Matt Johnston <matt@ucc.asn.au>
parents: 194
diff changeset
77 static const struct dropbear_cipher dropbear_3des =
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
78 {&des3_desc, 24, 8};
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
79 #endif
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
80
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
81 /* used to indicate no encryption, as defined in rfc2410 */
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
82 const struct dropbear_cipher dropbear_nocipher =
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
83 {NULL, 16, 8};
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
84
502
43bbe17d6ba0 - Add Counter Mode support
Matt Johnston <matt@ucc.asn.au>
parents: 501
diff changeset
85 /* A few void* s are required to silence warnings
43bbe17d6ba0 - Add Counter Mode support
Matt Johnston <matt@ucc.asn.au>
parents: 501
diff changeset
86 * about the symmetric_CBC vs symmetric_CTR cipher_state pointer */
992
731f624af902 Add config option to disable cbc. Disable twofish by default
Matt Johnston <matt@ucc.asn.au>
parents: 857
diff changeset
87 #ifdef DROPBEAR_ENABLE_CBC_MODE
502
43bbe17d6ba0 - Add Counter Mode support
Matt Johnston <matt@ucc.asn.au>
parents: 501
diff changeset
88 const struct dropbear_cipher_mode dropbear_mode_cbc =
43bbe17d6ba0 - Add Counter Mode support
Matt Johnston <matt@ucc.asn.au>
parents: 501
diff changeset
89 {(void*)cbc_start, (void*)cbc_encrypt, (void*)cbc_decrypt};
1038
d3925ed45a85 Fix for old compilers, variable declarations at beginning of functions
Thorsten Horstmann <thorsten.horstmann@web.de>
parents: 1019
diff changeset
90 #endif /* DROPBEAR_ENABLE_CBC_MODE */
992
731f624af902 Add config option to disable cbc. Disable twofish by default
Matt Johnston <matt@ucc.asn.au>
parents: 857
diff changeset
91
502
43bbe17d6ba0 - Add Counter Mode support
Matt Johnston <matt@ucc.asn.au>
parents: 501
diff changeset
92 const struct dropbear_cipher_mode dropbear_mode_none =
43bbe17d6ba0 - Add Counter Mode support
Matt Johnston <matt@ucc.asn.au>
parents: 501
diff changeset
93 {void_start, void_cipher, void_cipher};
992
731f624af902 Add config option to disable cbc. Disable twofish by default
Matt Johnston <matt@ucc.asn.au>
parents: 857
diff changeset
94
502
43bbe17d6ba0 - Add Counter Mode support
Matt Johnston <matt@ucc.asn.au>
parents: 501
diff changeset
95 #ifdef DROPBEAR_ENABLE_CTR_MODE
43bbe17d6ba0 - Add Counter Mode support
Matt Johnston <matt@ucc.asn.au>
parents: 501
diff changeset
96 /* a wrapper to make ctr_start and cbc_start look the same */
43bbe17d6ba0 - Add Counter Mode support
Matt Johnston <matt@ucc.asn.au>
parents: 501
diff changeset
97 static int dropbear_big_endian_ctr_start(int cipher,
43bbe17d6ba0 - Add Counter Mode support
Matt Johnston <matt@ucc.asn.au>
parents: 501
diff changeset
98 const unsigned char *IV,
43bbe17d6ba0 - Add Counter Mode support
Matt Johnston <matt@ucc.asn.au>
parents: 501
diff changeset
99 const unsigned char *key, int keylen,
43bbe17d6ba0 - Add Counter Mode support
Matt Johnston <matt@ucc.asn.au>
parents: 501
diff changeset
100 int num_rounds, symmetric_CTR *ctr) {
43bbe17d6ba0 - Add Counter Mode support
Matt Johnston <matt@ucc.asn.au>
parents: 501
diff changeset
101 return ctr_start(cipher, IV, key, keylen, num_rounds, CTR_COUNTER_BIG_ENDIAN, ctr);
43bbe17d6ba0 - Add Counter Mode support
Matt Johnston <matt@ucc.asn.au>
parents: 501
diff changeset
102 }
43bbe17d6ba0 - Add Counter Mode support
Matt Johnston <matt@ucc.asn.au>
parents: 501
diff changeset
103 const struct dropbear_cipher_mode dropbear_mode_ctr =
43bbe17d6ba0 - Add Counter Mode support
Matt Johnston <matt@ucc.asn.au>
parents: 501
diff changeset
104 {(void*)dropbear_big_endian_ctr_start, (void*)ctr_encrypt, (void*)ctr_decrypt};
1038
d3925ed45a85 Fix for old compilers, variable declarations at beginning of functions
Thorsten Horstmann <thorsten.horstmann@web.de>
parents: 1019
diff changeset
105 #endif /* DROPBEAR_ENABLE_CTR_MODE */
502
43bbe17d6ba0 - Add Counter Mode support
Matt Johnston <matt@ucc.asn.au>
parents: 501
diff changeset
106
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
107 /* Mapping of ssh hashes to libtomcrypt hashes, including keysize etc.
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
108 {&hash_desc, keysize, hashsize} */
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
109
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
110 #ifdef DROPBEAR_SHA1_HMAC
227
ad1b24e39bf3 Make a variables static
Matt Johnston <matt@ucc.asn.au>
parents: 194
diff changeset
111 static const struct dropbear_hash dropbear_sha1 =
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
112 {&sha1_desc, 20, 20};
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
113 #endif
228
5e4110bb753a - Fixed twofish algorithm naming so it actually works.
Matt Johnston <matt@ucc.asn.au>
parents: 227
diff changeset
114 #ifdef DROPBEAR_SHA1_96_HMAC
5e4110bb753a - Fixed twofish algorithm naming so it actually works.
Matt Johnston <matt@ucc.asn.au>
parents: 227
diff changeset
115 static const struct dropbear_hash dropbear_sha1_96 =
5e4110bb753a - Fixed twofish algorithm naming so it actually works.
Matt Johnston <matt@ucc.asn.au>
parents: 227
diff changeset
116 {&sha1_desc, 20, 12};
5e4110bb753a - Fixed twofish algorithm naming so it actually works.
Matt Johnston <matt@ucc.asn.au>
parents: 227
diff changeset
117 #endif
679
03073a27abb3 - Add hmac-sha2-256 and hmac-sha2-512. Needs debugging, seems to be
Matt Johnston <matt@ucc.asn.au>
parents: 595
diff changeset
118 #ifdef DROPBEAR_SHA2_256_HMAC
03073a27abb3 - Add hmac-sha2-256 and hmac-sha2-512. Needs debugging, seems to be
Matt Johnston <matt@ucc.asn.au>
parents: 595
diff changeset
119 static const struct dropbear_hash dropbear_sha2_256 =
03073a27abb3 - Add hmac-sha2-256 and hmac-sha2-512. Needs debugging, seems to be
Matt Johnston <matt@ucc.asn.au>
parents: 595
diff changeset
120 {&sha256_desc, 32, 32};
03073a27abb3 - Add hmac-sha2-256 and hmac-sha2-512. Needs debugging, seems to be
Matt Johnston <matt@ucc.asn.au>
parents: 595
diff changeset
121 #endif
03073a27abb3 - Add hmac-sha2-256 and hmac-sha2-512. Needs debugging, seems to be
Matt Johnston <matt@ucc.asn.au>
parents: 595
diff changeset
122 #ifdef DROPBEAR_SHA2_512_HMAC
03073a27abb3 - Add hmac-sha2-256 and hmac-sha2-512. Needs debugging, seems to be
Matt Johnston <matt@ucc.asn.au>
parents: 595
diff changeset
123 static const struct dropbear_hash dropbear_sha2_512 =
03073a27abb3 - Add hmac-sha2-256 and hmac-sha2-512. Needs debugging, seems to be
Matt Johnston <matt@ucc.asn.au>
parents: 595
diff changeset
124 {&sha512_desc, 64, 64};
03073a27abb3 - Add hmac-sha2-256 and hmac-sha2-512. Needs debugging, seems to be
Matt Johnston <matt@ucc.asn.au>
parents: 595
diff changeset
125 #endif
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
126 #ifdef DROPBEAR_MD5_HMAC
227
ad1b24e39bf3 Make a variables static
Matt Johnston <matt@ucc.asn.au>
parents: 194
diff changeset
127 static const struct dropbear_hash dropbear_md5 =
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
128 {&md5_desc, 16, 16};
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
129 #endif
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
130
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
131 const struct dropbear_hash dropbear_nohash =
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
132 {NULL, 16, 0}; /* used initially */
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
133
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
134
502
43bbe17d6ba0 - Add Counter Mode support
Matt Johnston <matt@ucc.asn.au>
parents: 501
diff changeset
135 /* The following map ssh names to internal values.
43bbe17d6ba0 - Add Counter Mode support
Matt Johnston <matt@ucc.asn.au>
parents: 501
diff changeset
136 * The ordering here is important for the client - the first mode
43bbe17d6ba0 - Add Counter Mode support
Matt Johnston <matt@ucc.asn.au>
parents: 501
diff changeset
137 * that is also supported by the server will get used. */
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
138
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
139 algo_type sshciphers[] = {
502
43bbe17d6ba0 - Add Counter Mode support
Matt Johnston <matt@ucc.asn.au>
parents: 501
diff changeset
140 #ifdef DROPBEAR_ENABLE_CTR_MODE
43bbe17d6ba0 - Add Counter Mode support
Matt Johnston <matt@ucc.asn.au>
parents: 501
diff changeset
141 #ifdef DROPBEAR_AES128
43bbe17d6ba0 - Add Counter Mode support
Matt Johnston <matt@ucc.asn.au>
parents: 501
diff changeset
142 {"aes128-ctr", 0, &dropbear_aes128, 1, &dropbear_mode_ctr},
43bbe17d6ba0 - Add Counter Mode support
Matt Johnston <matt@ucc.asn.au>
parents: 501
diff changeset
143 #endif
43bbe17d6ba0 - Add Counter Mode support
Matt Johnston <matt@ucc.asn.au>
parents: 501
diff changeset
144 #ifdef DROPBEAR_AES256
43bbe17d6ba0 - Add Counter Mode support
Matt Johnston <matt@ucc.asn.au>
parents: 501
diff changeset
145 {"aes256-ctr", 0, &dropbear_aes256, 1, &dropbear_mode_ctr},
43bbe17d6ba0 - Add Counter Mode support
Matt Johnston <matt@ucc.asn.au>
parents: 501
diff changeset
146 #endif
1087
1e486f368ec3 Disable twofish-ctr by default, add config option
Matt Johnston <matt@ucc.asn.au>
parents: 1038
diff changeset
147 #ifdef DROPBEAR_TWOFISH_CTR
1e486f368ec3 Disable twofish-ctr by default, add config option
Matt Johnston <matt@ucc.asn.au>
parents: 1038
diff changeset
148 /* twofish ctr is conditional as it hasn't been tested for interoperability, see options.h */
1012
ffd2359564b0 twofish ctr modes
Matt Johnston <matt@ucc.asn.au>
parents: 996
diff changeset
149 #ifdef DROPBEAR_TWOFISH256
ffd2359564b0 twofish ctr modes
Matt Johnston <matt@ucc.asn.au>
parents: 996
diff changeset
150 {"twofish256-ctr", 0, &dropbear_twofish256, 1, &dropbear_mode_ctr},
ffd2359564b0 twofish ctr modes
Matt Johnston <matt@ucc.asn.au>
parents: 996
diff changeset
151 #endif
ffd2359564b0 twofish ctr modes
Matt Johnston <matt@ucc.asn.au>
parents: 996
diff changeset
152 #ifdef DROPBEAR_TWOFISH128
ffd2359564b0 twofish ctr modes
Matt Johnston <matt@ucc.asn.au>
parents: 996
diff changeset
153 {"twofish128-ctr", 0, &dropbear_twofish128, 1, &dropbear_mode_ctr},
ffd2359564b0 twofish ctr modes
Matt Johnston <matt@ucc.asn.au>
parents: 996
diff changeset
154 #endif
1087
1e486f368ec3 Disable twofish-ctr by default, add config option
Matt Johnston <matt@ucc.asn.au>
parents: 1038
diff changeset
155 #endif /* DROPBEAR_TWOFISH_CTR */
502
43bbe17d6ba0 - Add Counter Mode support
Matt Johnston <matt@ucc.asn.au>
parents: 501
diff changeset
156 #endif /* DROPBEAR_ENABLE_CTR_MODE */
43bbe17d6ba0 - Add Counter Mode support
Matt Johnston <matt@ucc.asn.au>
parents: 501
diff changeset
157
992
731f624af902 Add config option to disable cbc. Disable twofish by default
Matt Johnston <matt@ucc.asn.au>
parents: 857
diff changeset
158 #ifdef DROPBEAR_ENABLE_CBC_MODE
502
43bbe17d6ba0 - Add Counter Mode support
Matt Johnston <matt@ucc.asn.au>
parents: 501
diff changeset
159 #ifdef DROPBEAR_AES128
43bbe17d6ba0 - Add Counter Mode support
Matt Johnston <matt@ucc.asn.au>
parents: 501
diff changeset
160 {"aes128-cbc", 0, &dropbear_aes128, 1, &dropbear_mode_cbc},
43bbe17d6ba0 - Add Counter Mode support
Matt Johnston <matt@ucc.asn.au>
parents: 501
diff changeset
161 #endif
43bbe17d6ba0 - Add Counter Mode support
Matt Johnston <matt@ucc.asn.au>
parents: 501
diff changeset
162 #ifdef DROPBEAR_AES256
43bbe17d6ba0 - Add Counter Mode support
Matt Johnston <matt@ucc.asn.au>
parents: 501
diff changeset
163 {"aes256-cbc", 0, &dropbear_aes256, 1, &dropbear_mode_cbc},
235
c3dbd3e1a8ce Change the preferred algorithm order
Matt Johnston <matt@ucc.asn.au>
parents: 234
diff changeset
164 #endif
502
43bbe17d6ba0 - Add Counter Mode support
Matt Johnston <matt@ucc.asn.au>
parents: 501
diff changeset
165 #ifdef DROPBEAR_TWOFISH256
43bbe17d6ba0 - Add Counter Mode support
Matt Johnston <matt@ucc.asn.au>
parents: 501
diff changeset
166 {"twofish256-cbc", 0, &dropbear_twofish256, 1, &dropbear_mode_cbc},
43bbe17d6ba0 - Add Counter Mode support
Matt Johnston <matt@ucc.asn.au>
parents: 501
diff changeset
167 {"twofish-cbc", 0, &dropbear_twofish256, 1, &dropbear_mode_cbc},
235
c3dbd3e1a8ce Change the preferred algorithm order
Matt Johnston <matt@ucc.asn.au>
parents: 234
diff changeset
168 #endif
502
43bbe17d6ba0 - Add Counter Mode support
Matt Johnston <matt@ucc.asn.au>
parents: 501
diff changeset
169 #ifdef DROPBEAR_TWOFISH128
43bbe17d6ba0 - Add Counter Mode support
Matt Johnston <matt@ucc.asn.au>
parents: 501
diff changeset
170 {"twofish128-cbc", 0, &dropbear_twofish128, 1, &dropbear_mode_cbc},
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
171 #endif
994
5c5ade336926 Prefer stronger algorithms in algorithm negotiation.
Fedor Brunner <fedor.brunner@azet.sk>
parents: 992
diff changeset
172 #ifdef DROPBEAR_3DES
5c5ade336926 Prefer stronger algorithms in algorithm negotiation.
Fedor Brunner <fedor.brunner@azet.sk>
parents: 992
diff changeset
173 {"3des-ctr", 0, &dropbear_3des, 1, &dropbear_mode_ctr},
5c5ade336926 Prefer stronger algorithms in algorithm negotiation.
Fedor Brunner <fedor.brunner@azet.sk>
parents: 992
diff changeset
174 #endif
5c5ade336926 Prefer stronger algorithms in algorithm negotiation.
Fedor Brunner <fedor.brunner@azet.sk>
parents: 992
diff changeset
175 #ifdef DROPBEAR_3DES
5c5ade336926 Prefer stronger algorithms in algorithm negotiation.
Fedor Brunner <fedor.brunner@azet.sk>
parents: 992
diff changeset
176 {"3des-cbc", 0, &dropbear_3des, 1, &dropbear_mode_cbc},
5c5ade336926 Prefer stronger algorithms in algorithm negotiation.
Fedor Brunner <fedor.brunner@azet.sk>
parents: 992
diff changeset
177 #endif
502
43bbe17d6ba0 - Add Counter Mode support
Matt Johnston <matt@ucc.asn.au>
parents: 501
diff changeset
178 #ifdef DROPBEAR_BLOWFISH
43bbe17d6ba0 - Add Counter Mode support
Matt Johnston <matt@ucc.asn.au>
parents: 501
diff changeset
179 {"blowfish-cbc", 0, &dropbear_blowfish, 1, &dropbear_mode_cbc},
43bbe17d6ba0 - Add Counter Mode support
Matt Johnston <matt@ucc.asn.au>
parents: 501
diff changeset
180 #endif
992
731f624af902 Add config option to disable cbc. Disable twofish by default
Matt Johnston <matt@ucc.asn.au>
parents: 857
diff changeset
181 #endif /* DROPBEAR_ENABLE_CBC_MODE */
252
29afa62b5450 - a hack for grahame to run dropbear with "none" cipher.
Matt Johnston <matt@ucc.asn.au>
parents: 238
diff changeset
182 #ifdef DROPBEAR_NONE_CIPHER
512
0129fd8ccc71 Update nocrypto branch to current head
Matt Johnston <matt@ucc.asn.au>
parents: 511
diff changeset
183 {"none", 0, (void*)&dropbear_nocipher, 1, &dropbear_mode_none},
252
29afa62b5450 - a hack for grahame to run dropbear with "none" cipher.
Matt Johnston <matt@ucc.asn.au>
parents: 238
diff changeset
184 #endif
502
43bbe17d6ba0 - Add Counter Mode support
Matt Johnston <matt@ucc.asn.au>
parents: 501
diff changeset
185 {NULL, 0, NULL, 0, NULL}
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
186 };
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
187
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
188 algo_type sshhashes[] = {
1017
a37f8730eb0f Keep sha1 default
Matt Johnston <matt@ucc.asn.au>
parents: 996
diff changeset
189 #ifdef DROPBEAR_SHA1_96_HMAC
a37f8730eb0f Keep sha1 default
Matt Johnston <matt@ucc.asn.au>
parents: 996
diff changeset
190 {"hmac-sha1-96", 0, &dropbear_sha1_96, 1, NULL},
a37f8730eb0f Keep sha1 default
Matt Johnston <matt@ucc.asn.au>
parents: 996
diff changeset
191 #endif
a37f8730eb0f Keep sha1 default
Matt Johnston <matt@ucc.asn.au>
parents: 996
diff changeset
192 #ifdef DROPBEAR_SHA1_HMAC
a37f8730eb0f Keep sha1 default
Matt Johnston <matt@ucc.asn.au>
parents: 996
diff changeset
193 {"hmac-sha1", 0, &dropbear_sha1, 1, NULL},
a37f8730eb0f Keep sha1 default
Matt Johnston <matt@ucc.asn.au>
parents: 996
diff changeset
194 #endif
679
03073a27abb3 - Add hmac-sha2-256 and hmac-sha2-512. Needs debugging, seems to be
Matt Johnston <matt@ucc.asn.au>
parents: 595
diff changeset
195 #ifdef DROPBEAR_SHA2_256_HMAC
715
cd3d3c63d189 Make hmac-sha2-256 and hmac-sha2-512 work
Matt Johnston <matt@ucc.asn.au>
parents: 686
diff changeset
196 {"hmac-sha2-256", 0, &dropbear_sha2_256, 1, NULL},
679
03073a27abb3 - Add hmac-sha2-256 and hmac-sha2-512. Needs debugging, seems to be
Matt Johnston <matt@ucc.asn.au>
parents: 595
diff changeset
197 #endif
03073a27abb3 - Add hmac-sha2-256 and hmac-sha2-512. Needs debugging, seems to be
Matt Johnston <matt@ucc.asn.au>
parents: 595
diff changeset
198 #ifdef DROPBEAR_SHA2_512_HMAC
715
cd3d3c63d189 Make hmac-sha2-256 and hmac-sha2-512 work
Matt Johnston <matt@ucc.asn.au>
parents: 686
diff changeset
199 {"hmac-sha2-512", 0, &dropbear_sha2_512, 1, NULL},
679
03073a27abb3 - Add hmac-sha2-256 and hmac-sha2-512. Needs debugging, seems to be
Matt Johnston <matt@ucc.asn.au>
parents: 595
diff changeset
200 #endif
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
201 #ifdef DROPBEAR_MD5_HMAC
681
a4b7627b3157 Update insecure-nocrypto to current head
Matt Johnston <matt@ucc.asn.au>
parents: 679 512
diff changeset
202 {"hmac-md5", 0, (void*)&dropbear_md5, 1, NULL},
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
203 #endif
252
29afa62b5450 - a hack for grahame to run dropbear with "none" cipher.
Matt Johnston <matt@ucc.asn.au>
parents: 238
diff changeset
204 #ifdef DROPBEAR_NONE_INTEGRITY
681
a4b7627b3157 Update insecure-nocrypto to current head
Matt Johnston <matt@ucc.asn.au>
parents: 679 512
diff changeset
205 {"none", 0, (void*)&dropbear_nohash, 1, NULL},
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
206 #endif
502
43bbe17d6ba0 - Add Counter Mode support
Matt Johnston <matt@ucc.asn.au>
parents: 501
diff changeset
207 {NULL, 0, NULL, 0, NULL}
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
208 };
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
209
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
210 #ifndef DISABLE_ZLIB
575
f9b5dc0cba61 - Disable compression for non-final multihops
Matt Johnston <matt@ucc.asn.au>
parents: 543
diff changeset
211 algo_type ssh_compress[] = {
994
5c5ade336926 Prefer stronger algorithms in algorithm negotiation.
Fedor Brunner <fedor.brunner@azet.sk>
parents: 992
diff changeset
212 {"[email protected]", DROPBEAR_COMP_ZLIB_DELAY, NULL, 1, NULL},
502
43bbe17d6ba0 - Add Counter Mode support
Matt Johnston <matt@ucc.asn.au>
parents: 501
diff changeset
213 {"zlib", DROPBEAR_COMP_ZLIB, NULL, 1, NULL},
575
f9b5dc0cba61 - Disable compression for non-final multihops
Matt Johnston <matt@ucc.asn.au>
parents: 543
diff changeset
214 {"none", DROPBEAR_COMP_NONE, NULL, 1, NULL},
f9b5dc0cba61 - Disable compression for non-final multihops
Matt Johnston <matt@ucc.asn.au>
parents: 543
diff changeset
215 {NULL, 0, NULL, 0, NULL}
f9b5dc0cba61 - Disable compression for non-final multihops
Matt Johnston <matt@ucc.asn.au>
parents: 543
diff changeset
216 };
996
47643024fc90 Disable non-delayed zlib for server
Matt Johnston <matt@ucc.asn.au>
parents: 994
diff changeset
217
47643024fc90 Disable non-delayed zlib for server
Matt Johnston <matt@ucc.asn.au>
parents: 994
diff changeset
218 algo_type ssh_delaycompress[] = {
47643024fc90 Disable non-delayed zlib for server
Matt Johnston <matt@ucc.asn.au>
parents: 994
diff changeset
219 {"[email protected]", DROPBEAR_COMP_ZLIB_DELAY, NULL, 1, NULL},
47643024fc90 Disable non-delayed zlib for server
Matt Johnston <matt@ucc.asn.au>
parents: 994
diff changeset
220 {"none", DROPBEAR_COMP_NONE, NULL, 1, NULL},
47643024fc90 Disable non-delayed zlib for server
Matt Johnston <matt@ucc.asn.au>
parents: 994
diff changeset
221 {NULL, 0, NULL, 0, NULL}
47643024fc90 Disable non-delayed zlib for server
Matt Johnston <matt@ucc.asn.au>
parents: 994
diff changeset
222 };
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
223 #endif
575
f9b5dc0cba61 - Disable compression for non-final multihops
Matt Johnston <matt@ucc.asn.au>
parents: 543
diff changeset
224
f9b5dc0cba61 - Disable compression for non-final multihops
Matt Johnston <matt@ucc.asn.au>
parents: 543
diff changeset
225 algo_type ssh_nocompress[] = {
502
43bbe17d6ba0 - Add Counter Mode support
Matt Johnston <matt@ucc.asn.au>
parents: 501
diff changeset
226 {"none", DROPBEAR_COMP_NONE, NULL, 1, NULL},
43bbe17d6ba0 - Add Counter Mode support
Matt Johnston <matt@ucc.asn.au>
parents: 501
diff changeset
227 {NULL, 0, NULL, 0, NULL}
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
228 };
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
229
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
230 algo_type sshhostkey[] = {
795
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 766
diff changeset
231 #ifdef DROPBEAR_ECDSA
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 766
diff changeset
232 #ifdef DROPBEAR_ECC_256
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 766
diff changeset
233 {"ecdsa-sha2-nistp256", DROPBEAR_SIGNKEY_ECDSA_NISTP256, NULL, 1, NULL},
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 766
diff changeset
234 #endif
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 766
diff changeset
235 #ifdef DROPBEAR_ECC_384
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 766
diff changeset
236 {"ecdsa-sha2-nistp384", DROPBEAR_SIGNKEY_ECDSA_NISTP384, NULL, 1, NULL},
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 766
diff changeset
237 #endif
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 766
diff changeset
238 #ifdef DROPBEAR_ECC_521
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 766
diff changeset
239 {"ecdsa-sha2-nistp521", DROPBEAR_SIGNKEY_ECDSA_NISTP521, NULL, 1, NULL},
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 766
diff changeset
240 #endif
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 766
diff changeset
241 #endif
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
242 #ifdef DROPBEAR_RSA
502
43bbe17d6ba0 - Add Counter Mode support
Matt Johnston <matt@ucc.asn.au>
parents: 501
diff changeset
243 {"ssh-rsa", DROPBEAR_SIGNKEY_RSA, NULL, 1, NULL},
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
244 #endif
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
245 #ifdef DROPBEAR_DSS
502
43bbe17d6ba0 - Add Counter Mode support
Matt Johnston <matt@ucc.asn.au>
parents: 501
diff changeset
246 {"ssh-dss", DROPBEAR_SIGNKEY_DSS, NULL, 1, NULL},
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
247 #endif
502
43bbe17d6ba0 - Add Counter Mode support
Matt Johnston <matt@ucc.asn.au>
parents: 501
diff changeset
248 {NULL, 0, NULL, 0, NULL}
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
249 };
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
250
1248
739b3909c499 Get rid of group15, move group16 to sha512.
Matt Johnston <matt@ucc.asn.au>
parents: 1225
diff changeset
251 #if DROPBEAR_DH_GROUP1
848
6c69e7df3621 curve25519
Matt Johnston <matt@ucc.asn.au>
parents: 840
diff changeset
252 static const struct dropbear_kex kex_dh_group1 = {DROPBEAR_KEX_NORMAL_DH, dh_p_1, DH_P_1_LEN, NULL, &sha1_desc };
1248
739b3909c499 Get rid of group15, move group16 to sha512.
Matt Johnston <matt@ucc.asn.au>
parents: 1225
diff changeset
253 #endif
739b3909c499 Get rid of group15, move group16 to sha512.
Matt Johnston <matt@ucc.asn.au>
parents: 1225
diff changeset
254 #if DROPBEAR_DH_GROUP14
1204
d2f9ef67af15 diffie-hellman-group14-sha256
Matt Johnston <matt@ucc.asn.au>
parents: 1124
diff changeset
255 static const struct dropbear_kex kex_dh_group14_sha1 = {DROPBEAR_KEX_NORMAL_DH, dh_p_14, DH_P_14_LEN, NULL, &sha1_desc };
1248
739b3909c499 Get rid of group15, move group16 to sha512.
Matt Johnston <matt@ucc.asn.au>
parents: 1225
diff changeset
256 #if DROPBEAR_DH_GROUP14_256
1204
d2f9ef67af15 diffie-hellman-group14-sha256
Matt Johnston <matt@ucc.asn.au>
parents: 1124
diff changeset
257 static const struct dropbear_kex kex_dh_group14_sha256 = {DROPBEAR_KEX_NORMAL_DH, dh_p_14, DH_P_14_LEN, NULL, &sha256_desc };
1248
739b3909c499 Get rid of group15, move group16 to sha512.
Matt Johnston <matt@ucc.asn.au>
parents: 1225
diff changeset
258 #endif
1225
6a7938ba004a add dh group15 and group16, disabled by default
Matt Johnston <matt@ucc.asn.au>
parents: 1224
diff changeset
259 #endif
1248
739b3909c499 Get rid of group15, move group16 to sha512.
Matt Johnston <matt@ucc.asn.au>
parents: 1225
diff changeset
260 #if DROPBEAR_DH_GROUP16
739b3909c499 Get rid of group15, move group16 to sha512.
Matt Johnston <matt@ucc.asn.au>
parents: 1225
diff changeset
261 static const struct dropbear_kex kex_dh_group16_sha512 = {DROPBEAR_KEX_NORMAL_DH, dh_p_16, DH_P_16_LEN, NULL, &sha512_desc };
1225
6a7938ba004a add dh group15 and group16, disabled by default
Matt Johnston <matt@ucc.asn.au>
parents: 1224
diff changeset
262 #endif
756
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
263
852
7540c0822374 Various cleanups and fixes for warnings
Matt Johnston <matt@ucc.asn.au>
parents: 848
diff changeset
264 /* These can't be const since dropbear_ecc_fill_dp() fills out
7540c0822374 Various cleanups and fixes for warnings
Matt Johnston <matt@ucc.asn.au>
parents: 848
diff changeset
265 ecc_curve at runtime */
761
ac2158e3e403 ecc kind of works, needs fixing/testing
Matt Johnston <matt@ucc.asn.au>
parents: 759
diff changeset
266 #ifdef DROPBEAR_ECDH
756
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
267 #ifdef DROPBEAR_ECC_256
1273
139935236c72 const variables
Francois Perrad <francois.perrad@gadz.org>
parents: 1248
diff changeset
268 static const struct dropbear_kex kex_ecdh_nistp256 = {DROPBEAR_KEX_ECDH, NULL, 0, &ecc_curve_nistp256, &sha256_desc };
756
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
269 #endif
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
270 #ifdef DROPBEAR_ECC_384
1273
139935236c72 const variables
Francois Perrad <francois.perrad@gadz.org>
parents: 1248
diff changeset
271 static const struct dropbear_kex kex_ecdh_nistp384 = {DROPBEAR_KEX_ECDH, NULL, 0, &ecc_curve_nistp384, &sha384_desc };
756
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
272 #endif
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
273 #ifdef DROPBEAR_ECC_521
1273
139935236c72 const variables
Francois Perrad <francois.perrad@gadz.org>
parents: 1248
diff changeset
274 static const struct dropbear_kex kex_ecdh_nistp521 = {DROPBEAR_KEX_ECDH, NULL, 0, &ecc_curve_nistp521, &sha512_desc };
756
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
275 #endif
848
6c69e7df3621 curve25519
Matt Johnston <matt@ucc.asn.au>
parents: 840
diff changeset
276 #endif /* DROPBEAR_ECDH */
756
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
277
848
6c69e7df3621 curve25519
Matt Johnston <matt@ucc.asn.au>
parents: 840
diff changeset
278 #ifdef DROPBEAR_CURVE25519
6c69e7df3621 curve25519
Matt Johnston <matt@ucc.asn.au>
parents: 840
diff changeset
279 /* Referred to directly */
852
7540c0822374 Various cleanups and fixes for warnings
Matt Johnston <matt@ucc.asn.au>
parents: 848
diff changeset
280 static const struct dropbear_kex kex_curve25519 = {DROPBEAR_KEX_CURVE25519, NULL, 0, NULL, &sha256_desc };
848
6c69e7df3621 curve25519
Matt Johnston <matt@ucc.asn.au>
parents: 840
diff changeset
281 #endif
756
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
282
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
283 algo_type sshkex[] = {
848
6c69e7df3621 curve25519
Matt Johnston <matt@ucc.asn.au>
parents: 840
diff changeset
284 #ifdef DROPBEAR_CURVE25519
6c69e7df3621 curve25519
Matt Johnston <matt@ucc.asn.au>
parents: 840
diff changeset
285 {"[email protected]", 0, &kex_curve25519, 1, NULL},
6c69e7df3621 curve25519
Matt Johnston <matt@ucc.asn.au>
parents: 840
diff changeset
286 #endif
761
ac2158e3e403 ecc kind of works, needs fixing/testing
Matt Johnston <matt@ucc.asn.au>
parents: 759
diff changeset
287 #ifdef DROPBEAR_ECDH
840
5128e525c8fa Default to some larger key sizes
Matt Johnston <matt@ucc.asn.au>
parents: 801
diff changeset
288 #ifdef DROPBEAR_ECC_521
5128e525c8fa Default to some larger key sizes
Matt Johnston <matt@ucc.asn.au>
parents: 801
diff changeset
289 {"ecdh-sha2-nistp521", 0, &kex_ecdh_nistp521, 1, NULL},
756
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
290 #endif
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
291 #ifdef DROPBEAR_ECC_384
762
a78a38e402d1 - Fix various hardcoded uses of SHA1
Matt Johnston <matt@ucc.asn.au>
parents: 761
diff changeset
292 {"ecdh-sha2-nistp384", 0, &kex_ecdh_nistp384, 1, NULL},
756
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
293 #endif
840
5128e525c8fa Default to some larger key sizes
Matt Johnston <matt@ucc.asn.au>
parents: 801
diff changeset
294 #ifdef DROPBEAR_ECC_256
5128e525c8fa Default to some larger key sizes
Matt Johnston <matt@ucc.asn.au>
parents: 801
diff changeset
295 {"ecdh-sha2-nistp256", 0, &kex_ecdh_nistp256, 1, NULL},
756
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
296 #endif
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
297 #endif
1248
739b3909c499 Get rid of group15, move group16 to sha512.
Matt Johnston <matt@ucc.asn.au>
parents: 1225
diff changeset
298 #if DROPBEAR_DH_GROUP14
739b3909c499 Get rid of group15, move group16 to sha512.
Matt Johnston <matt@ucc.asn.au>
parents: 1225
diff changeset
299 #if DROPBEAR_DH_GROUP14_256
1204
d2f9ef67af15 diffie-hellman-group14-sha256
Matt Johnston <matt@ucc.asn.au>
parents: 1124
diff changeset
300 {"diffie-hellman-group14-sha256", 0, &kex_dh_group14_sha256, 1, NULL},
1248
739b3909c499 Get rid of group15, move group16 to sha512.
Matt Johnston <matt@ucc.asn.au>
parents: 1225
diff changeset
301 #endif
1204
d2f9ef67af15 diffie-hellman-group14-sha256
Matt Johnston <matt@ucc.asn.au>
parents: 1124
diff changeset
302 {"diffie-hellman-group14-sha1", 0, &kex_dh_group14_sha1, 1, NULL},
1248
739b3909c499 Get rid of group15, move group16 to sha512.
Matt Johnston <matt@ucc.asn.au>
parents: 1225
diff changeset
303 #endif
739b3909c499 Get rid of group15, move group16 to sha512.
Matt Johnston <matt@ucc.asn.au>
parents: 1225
diff changeset
304 #if DROPBEAR_DH_GROUP1
756
bf9dc2d9c2b1 more bits on ecc branch
Matt Johnston <matt@ucc.asn.au>
parents: 755
diff changeset
305 {"diffie-hellman-group1-sha1", 0, &kex_dh_group1, 1, NULL},
1225
6a7938ba004a add dh group15 and group16, disabled by default
Matt Johnston <matt@ucc.asn.au>
parents: 1224
diff changeset
306 #endif
1248
739b3909c499 Get rid of group15, move group16 to sha512.
Matt Johnston <matt@ucc.asn.au>
parents: 1225
diff changeset
307 #if DROPBEAR_DH_GROUP16
739b3909c499 Get rid of group15, move group16 to sha512.
Matt Johnston <matt@ucc.asn.au>
parents: 1225
diff changeset
308 {"diffie-hellman-group16-sha512", 0, &kex_dh_group16_sha512, 1, NULL},
1225
6a7938ba004a add dh group15 and group16, disabled by default
Matt Johnston <matt@ucc.asn.au>
parents: 1224
diff changeset
309 #endif
746
465fefc4f6e0 Put some #ifdef options around first-follows options in case they
Matt Johnston <matt@ucc.asn.au>
parents: 745
diff changeset
310 #ifdef USE_KEXGUESS2
740
3062da90dab8 Add kexguess2 behaviour
Matt Johnston <matt@ucc.asn.au>
parents: 715
diff changeset
311 {KEXGUESS2_ALGO_NAME, KEXGUESS2_ALGO_ID, NULL, 1, NULL},
746
465fefc4f6e0 Put some #ifdef options around first-follows options in case they
Matt Johnston <matt@ucc.asn.au>
parents: 745
diff changeset
312 #endif
502
43bbe17d6ba0 - Add Counter Mode support
Matt Johnston <matt@ucc.asn.au>
parents: 501
diff changeset
313 {NULL, 0, NULL, 0, NULL}
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
314 };
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
315
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
316 /* algolen specifies the length of algo, algos is our local list to match
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
317 * against.
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
318 * Returns DROPBEAR_SUCCESS if we have a match for algo, DROPBEAR_FAILURE
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
319 * otherwise */
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
320 int have_algo(char* algo, size_t algolen, algo_type algos[]) {
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
321
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
322 int i;
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
323
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
324 for (i = 0; algos[i].name != NULL; i++) {
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
325 if (strlen(algos[i].name) == algolen
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
326 && (strncmp(algos[i].name, algo, algolen) == 0)) {
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
327 return DROPBEAR_SUCCESS;
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
328 }
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
329 }
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
330
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
331 return DROPBEAR_FAILURE;
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
332 }
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
333
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
334 /* Output a comma separated list of algorithms to a buffer */
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
335 void buf_put_algolist(buffer * buf, algo_type localalgos[]) {
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
336
238
e923801a7678 use a buffer rather than raw char array for creating
Matt Johnston <matt@ucc.asn.au>
parents: 237
diff changeset
337 unsigned int i, len;
e923801a7678 use a buffer rather than raw char array for creating
Matt Johnston <matt@ucc.asn.au>
parents: 237
diff changeset
338 unsigned int donefirst = 0;
e923801a7678 use a buffer rather than raw char array for creating
Matt Johnston <matt@ucc.asn.au>
parents: 237
diff changeset
339 buffer *algolist = NULL;
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
340
1225
6a7938ba004a add dh group15 and group16, disabled by default
Matt Johnston <matt@ucc.asn.au>
parents: 1224
diff changeset
341 algolist = buf_new(300);
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
342 for (i = 0; localalgos[i].name != NULL; i++) {
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
343 if (localalgos[i].usable) {
238
e923801a7678 use a buffer rather than raw char array for creating
Matt Johnston <matt@ucc.asn.au>
parents: 237
diff changeset
344 if (donefirst)
e923801a7678 use a buffer rather than raw char array for creating
Matt Johnston <matt@ucc.asn.au>
parents: 237
diff changeset
345 buf_putbyte(algolist, ',');
e923801a7678 use a buffer rather than raw char array for creating
Matt Johnston <matt@ucc.asn.au>
parents: 237
diff changeset
346 donefirst = 1;
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
347 len = strlen(localalgos[i].name);
1106
2052b53d3034 Turn Algo_Type's name attribute into const char *
Gaël PORTAY <gael.portay@gmail.com>
parents: 1094
diff changeset
348 buf_putbytes(algolist, (const unsigned char *) localalgos[i].name, len);
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
349 }
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
350 }
1122
aaf576b27a10 Merge pull request #13 from gazoo74/fix-warnings
Matt Johnston <matt@ucc.asn.au>
parents: 1087 1106
diff changeset
351 buf_putstring(buf, (const char*)algolist->data, algolist->len);
238
e923801a7678 use a buffer rather than raw char array for creating
Matt Johnston <matt@ucc.asn.au>
parents: 237
diff changeset
352 buf_free(algolist);
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
353 }
682
4edea9f363d0 Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents: 595
diff changeset
354
741
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
355 /* match the first algorithm in the comma-separated list in buf which is
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
356 * also in localalgos[], or return NULL on failure.
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
357 * (*goodguess) is set to 1 if the preferred client/server algos match,
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
358 * 0 otherwise. This is used for checking if the kexalgo/hostkeyalgos are
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
359 * guessed correctly */
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
360 algo_type * buf_match_algo(buffer* buf, algo_type localalgos[],
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
361 enum kexguess2_used *kexguess2, int *goodguess)
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
362 {
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
363
1094
c45d65392c1a Fix pointer differ in signess warnings [-Werror=pointer-sign]
Gaël PORTAY <gael.portay@gmail.com>
parents: 1038
diff changeset
364 char * algolist = NULL;
c45d65392c1a Fix pointer differ in signess warnings [-Werror=pointer-sign]
Gaël PORTAY <gael.portay@gmail.com>
parents: 1038
diff changeset
365 const char *remotenames[MAX_PROPOSED_ALGO], *localnames[MAX_PROPOSED_ALGO];
741
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
366 unsigned int len;
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
367 unsigned int remotecount, localcount, clicount, servcount, i, j;
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
368 algo_type * ret = NULL;
1094
c45d65392c1a Fix pointer differ in signess warnings [-Werror=pointer-sign]
Gaël PORTAY <gael.portay@gmail.com>
parents: 1038
diff changeset
369 const char **clinames, **servnames;
741
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
370
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
371 if (goodguess) {
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
372 *goodguess = 0;
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
373 }
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
374
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
375 /* get the comma-separated list from the buffer ie "algo1,algo2,algo3" */
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
376 algolist = buf_getstring(buf, &len);
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
377 TRACE(("buf_match_algo: %s", algolist))
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
378 if (len > MAX_PROPOSED_ALGO*(MAX_NAME_LEN+1)) {
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
379 goto out;
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
380 }
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
381
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
382 /* remotenames will contain a list of the strings parsed out */
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
383 /* We will have at least one string (even if it's just "") */
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
384 remotenames[0] = algolist;
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
385 remotecount = 1;
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
386 for (i = 0; i < len; i++) {
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
387 if (algolist[i] == '\0') {
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
388 /* someone is trying something strange */
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
389 goto out;
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
390 }
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
391 if (algolist[i] == ',') {
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
392 algolist[i] = '\0';
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
393 remotenames[remotecount] = &algolist[i+1];
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
394 remotecount++;
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
395 }
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
396 if (remotecount >= MAX_PROPOSED_ALGO) {
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
397 break;
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
398 }
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
399 }
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
400 if (kexguess2 && *kexguess2 == KEXGUESS2_LOOK) {
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
401 for (i = 0; i < remotecount; i++)
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
402 {
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
403 if (strcmp(remotenames[i], KEXGUESS2_ALGO_NAME) == 0) {
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
404 *kexguess2 = KEXGUESS2_YES;
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
405 break;
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
406 }
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
407 }
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
408 if (*kexguess2 == KEXGUESS2_LOOK) {
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
409 *kexguess2 = KEXGUESS2_NO;
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
410 }
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
411 }
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
412
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
413 for (i = 0; localalgos[i].name != NULL; i++) {
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
414 if (localalgos[i].usable) {
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
415 localnames[i] = localalgos[i].name;
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
416 } else {
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
417 localnames[i] = NULL;
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
418 }
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
419 }
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
420 localcount = i;
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
421
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
422 if (IS_DROPBEAR_SERVER) {
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
423 clinames = remotenames;
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
424 clicount = remotecount;
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
425 servnames = localnames;
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
426 servcount = localcount;
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
427 } else {
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
428 clinames = localnames;
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
429 clicount = localcount;
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
430 servnames = remotenames;
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
431 servcount = remotecount;
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
432 }
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
433
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
434 /* iterate and find the first match */
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
435 for (i = 0; i < clicount; i++) {
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
436 for (j = 0; j < servcount; j++) {
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
437 if (!(servnames[j] && clinames[i])) {
857
c19acba28590 use oldstyle comments
Matt Johnston <matt@ucc.asn.au>
parents: 852
diff changeset
438 /* unusable algos are NULL */
741
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
439 continue;
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
440 }
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
441 if (strcmp(servnames[j], clinames[i]) == 0) {
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
442 /* set if it was a good guess */
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
443 if (goodguess && kexguess2) {
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
444 if (*kexguess2 == KEXGUESS2_YES) {
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
445 if (i == 0) {
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
446 *goodguess = 1;
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
447 }
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
448
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
449 } else {
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
450 if (i == 0 && j == 0) {
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
451 *goodguess = 1;
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
452 }
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
453 }
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
454 }
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
455 /* set the algo to return */
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
456 if (IS_DROPBEAR_SERVER) {
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
457 ret = &localalgos[j];
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
458 } else {
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
459 ret = &localalgos[i];
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
460 }
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
461 goto out;
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
462 }
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
463 }
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
464 }
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
465
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
466 out:
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
467 m_free(algolist);
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
468 return ret;
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
469 }
eafdf8b363f5 Get rid of client/server specific buf_match_algo, use single
Matt Johnston <matt@ucc.asn.au>
parents: 740
diff changeset
470
686
983a817f8e41 - Only request "none" cipher after auth has succeeded
Matt Johnston <matt@ucc.asn.au>
parents: 684
diff changeset
471 #ifdef DROPBEAR_NONE_CIPHER
983a817f8e41 - Only request "none" cipher after auth has succeeded
Matt Johnston <matt@ucc.asn.au>
parents: 684
diff changeset
472
983a817f8e41 - Only request "none" cipher after auth has succeeded
Matt Johnston <matt@ucc.asn.au>
parents: 684
diff changeset
473 void
983a817f8e41 - Only request "none" cipher after auth has succeeded
Matt Johnston <matt@ucc.asn.au>
parents: 684
diff changeset
474 set_algo_usable(algo_type algos[], const char * algo_name, int usable)
983a817f8e41 - Only request "none" cipher after auth has succeeded
Matt Johnston <matt@ucc.asn.au>
parents: 684
diff changeset
475 {
983a817f8e41 - Only request "none" cipher after auth has succeeded
Matt Johnston <matt@ucc.asn.au>
parents: 684
diff changeset
476 algo_type *a;
983a817f8e41 - Only request "none" cipher after auth has succeeded
Matt Johnston <matt@ucc.asn.au>
parents: 684
diff changeset
477 for (a = algos; a->name != NULL; a++)
983a817f8e41 - Only request "none" cipher after auth has succeeded
Matt Johnston <matt@ucc.asn.au>
parents: 684
diff changeset
478 {
983a817f8e41 - Only request "none" cipher after auth has succeeded
Matt Johnston <matt@ucc.asn.au>
parents: 684
diff changeset
479 if (strcmp(a->name, algo_name) == 0)
983a817f8e41 - Only request "none" cipher after auth has succeeded
Matt Johnston <matt@ucc.asn.au>
parents: 684
diff changeset
480 {
983a817f8e41 - Only request "none" cipher after auth has succeeded
Matt Johnston <matt@ucc.asn.au>
parents: 684
diff changeset
481 a->usable = usable;
983a817f8e41 - Only request "none" cipher after auth has succeeded
Matt Johnston <matt@ucc.asn.au>
parents: 684
diff changeset
482 return;
983a817f8e41 - Only request "none" cipher after auth has succeeded
Matt Johnston <matt@ucc.asn.au>
parents: 684
diff changeset
483 }
983a817f8e41 - Only request "none" cipher after auth has succeeded
Matt Johnston <matt@ucc.asn.au>
parents: 684
diff changeset
484 }
983a817f8e41 - Only request "none" cipher after auth has succeeded
Matt Johnston <matt@ucc.asn.au>
parents: 684
diff changeset
485 }
983a817f8e41 - Only request "none" cipher after auth has succeeded
Matt Johnston <matt@ucc.asn.au>
parents: 684
diff changeset
486
983a817f8e41 - Only request "none" cipher after auth has succeeded
Matt Johnston <matt@ucc.asn.au>
parents: 684
diff changeset
487 int
983a817f8e41 - Only request "none" cipher after auth has succeeded
Matt Johnston <matt@ucc.asn.au>
parents: 684
diff changeset
488 get_algo_usable(algo_type algos[], const char * algo_name)
983a817f8e41 - Only request "none" cipher after auth has succeeded
Matt Johnston <matt@ucc.asn.au>
parents: 684
diff changeset
489 {
983a817f8e41 - Only request "none" cipher after auth has succeeded
Matt Johnston <matt@ucc.asn.au>
parents: 684
diff changeset
490 algo_type *a;
983a817f8e41 - Only request "none" cipher after auth has succeeded
Matt Johnston <matt@ucc.asn.au>
parents: 684
diff changeset
491 for (a = algos; a->name != NULL; a++)
983a817f8e41 - Only request "none" cipher after auth has succeeded
Matt Johnston <matt@ucc.asn.au>
parents: 684
diff changeset
492 {
983a817f8e41 - Only request "none" cipher after auth has succeeded
Matt Johnston <matt@ucc.asn.au>
parents: 684
diff changeset
493 if (strcmp(a->name, algo_name) == 0)
983a817f8e41 - Only request "none" cipher after auth has succeeded
Matt Johnston <matt@ucc.asn.au>
parents: 684
diff changeset
494 {
983a817f8e41 - Only request "none" cipher after auth has succeeded
Matt Johnston <matt@ucc.asn.au>
parents: 684
diff changeset
495 return a->usable;
983a817f8e41 - Only request "none" cipher after auth has succeeded
Matt Johnston <matt@ucc.asn.au>
parents: 684
diff changeset
496 }
983a817f8e41 - Only request "none" cipher after auth has succeeded
Matt Johnston <matt@ucc.asn.au>
parents: 684
diff changeset
497 }
983a817f8e41 - Only request "none" cipher after auth has succeeded
Matt Johnston <matt@ucc.asn.au>
parents: 684
diff changeset
498 return 0;
983a817f8e41 - Only request "none" cipher after auth has succeeded
Matt Johnston <matt@ucc.asn.au>
parents: 684
diff changeset
499 }
983a817f8e41 - Only request "none" cipher after auth has succeeded
Matt Johnston <matt@ucc.asn.au>
parents: 684
diff changeset
500
857
c19acba28590 use oldstyle comments
Matt Johnston <matt@ucc.asn.au>
parents: 852
diff changeset
501 #endif /* DROPBEAR_NONE_CIPHER */
686
983a817f8e41 - Only request "none" cipher after auth has succeeded
Matt Johnston <matt@ucc.asn.au>
parents: 684
diff changeset
502
682
4edea9f363d0 Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents: 595
diff changeset
503 #ifdef ENABLE_USER_ALGO_LIST
4edea9f363d0 Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents: 595
diff changeset
504
4edea9f363d0 Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents: 595
diff changeset
505 char *
4edea9f363d0 Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents: 595
diff changeset
506 algolist_string(algo_type algos[])
4edea9f363d0 Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents: 595
diff changeset
507 {
4edea9f363d0 Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents: 595
diff changeset
508 char *ret_list;
4edea9f363d0 Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents: 595
diff changeset
509 buffer *b = buf_new(200);
4edea9f363d0 Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents: 595
diff changeset
510 buf_put_algolist(b, algos);
4edea9f363d0 Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents: 595
diff changeset
511 buf_setpos(b, b->len);
4edea9f363d0 Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents: 595
diff changeset
512 buf_putbyte(b, '\0');
4edea9f363d0 Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents: 595
diff changeset
513 buf_setpos(b, 4);
1094
c45d65392c1a Fix pointer differ in signess warnings [-Werror=pointer-sign]
Gaël PORTAY <gael.portay@gmail.com>
parents: 1038
diff changeset
514 ret_list = m_strdup((const char *) buf_getptr(b, b->len - b->pos));
682
4edea9f363d0 Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents: 595
diff changeset
515 buf_free(b);
4edea9f363d0 Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents: 595
diff changeset
516 return ret_list;
4edea9f363d0 Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents: 595
diff changeset
517 }
4edea9f363d0 Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents: 595
diff changeset
518
683
63f8d6c469cf ENABLE_USER_ALGO_LIST should work for the client
Matt Johnston <matt@ucc.asn.au>
parents: 682
diff changeset
519 static algo_type*
682
4edea9f363d0 Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents: 595
diff changeset
520 check_algo(const char* algo_name, algo_type *algos)
4edea9f363d0 Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents: 595
diff changeset
521 {
4edea9f363d0 Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents: 595
diff changeset
522 algo_type *a;
4edea9f363d0 Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents: 595
diff changeset
523 for (a = algos; a->name != NULL; a++)
4edea9f363d0 Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents: 595
diff changeset
524 {
4edea9f363d0 Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents: 595
diff changeset
525 if (strcmp(a->name, algo_name) == 0)
4edea9f363d0 Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents: 595
diff changeset
526 {
683
63f8d6c469cf ENABLE_USER_ALGO_LIST should work for the client
Matt Johnston <matt@ucc.asn.au>
parents: 682
diff changeset
527 return a;
682
4edea9f363d0 Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents: 595
diff changeset
528 }
4edea9f363d0 Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents: 595
diff changeset
529 }
4edea9f363d0 Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents: 595
diff changeset
530
683
63f8d6c469cf ENABLE_USER_ALGO_LIST should work for the client
Matt Johnston <matt@ucc.asn.au>
parents: 682
diff changeset
531 return NULL;
682
4edea9f363d0 Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents: 595
diff changeset
532 }
4edea9f363d0 Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents: 595
diff changeset
533
4edea9f363d0 Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents: 595
diff changeset
534 /* Checks a user provided comma-separated algorithm list for available
4edea9f363d0 Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents: 595
diff changeset
535 * options. Any that are not acceptable are removed in-place. Returns the
4edea9f363d0 Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents: 595
diff changeset
536 * number of valid algorithms. */
4edea9f363d0 Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents: 595
diff changeset
537 int
683
63f8d6c469cf ENABLE_USER_ALGO_LIST should work for the client
Matt Johnston <matt@ucc.asn.au>
parents: 682
diff changeset
538 check_user_algos(const char* user_algo_list, algo_type * algos,
682
4edea9f363d0 Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents: 595
diff changeset
539 const char *algo_desc)
4edea9f363d0 Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents: 595
diff changeset
540 {
1303
eed9376a4ad6 improve algorithm list parsing
Matt Johnston <matt@ucc.asn.au>
parents: 1273
diff changeset
541 algo_type new_algos[MAX_PROPOSED_ALGO+1];
682
4edea9f363d0 Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents: 595
diff changeset
542 char *work_list = m_strdup(user_algo_list);
1303
eed9376a4ad6 improve algorithm list parsing
Matt Johnston <matt@ucc.asn.au>
parents: 1273
diff changeset
543 char *start = work_list;
682
4edea9f363d0 Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents: 595
diff changeset
544 char *c;
1303
eed9376a4ad6 improve algorithm list parsing
Matt Johnston <matt@ucc.asn.au>
parents: 1273
diff changeset
545 int n;
eed9376a4ad6 improve algorithm list parsing
Matt Johnston <matt@ucc.asn.au>
parents: 1273
diff changeset
546 /* So we can iterate and look for null terminator */
eed9376a4ad6 improve algorithm list parsing
Matt Johnston <matt@ucc.asn.au>
parents: 1273
diff changeset
547 memset(new_algos, 0x0, sizeof(new_algos));
eed9376a4ad6 improve algorithm list parsing
Matt Johnston <matt@ucc.asn.au>
parents: 1273
diff changeset
548 for (c = work_list, n = 0; ; c++)
682
4edea9f363d0 Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents: 595
diff changeset
549 {
1303
eed9376a4ad6 improve algorithm list parsing
Matt Johnston <matt@ucc.asn.au>
parents: 1273
diff changeset
550 char oc = *c;
eed9376a4ad6 improve algorithm list parsing
Matt Johnston <matt@ucc.asn.au>
parents: 1273
diff changeset
551 if (n >= MAX_PROPOSED_ALGO) {
eed9376a4ad6 improve algorithm list parsing
Matt Johnston <matt@ucc.asn.au>
parents: 1273
diff changeset
552 dropbear_exit("Too many algorithms '%s'", user_algo_list);
eed9376a4ad6 improve algorithm list parsing
Matt Johnston <matt@ucc.asn.au>
parents: 1273
diff changeset
553 }
eed9376a4ad6 improve algorithm list parsing
Matt Johnston <matt@ucc.asn.au>
parents: 1273
diff changeset
554 if (*c == ',' || *c == '\0') {
eed9376a4ad6 improve algorithm list parsing
Matt Johnston <matt@ucc.asn.au>
parents: 1273
diff changeset
555 algo_type *match_algo = NULL;
682
4edea9f363d0 Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents: 595
diff changeset
556 *c = '\0';
1303
eed9376a4ad6 improve algorithm list parsing
Matt Johnston <matt@ucc.asn.au>
parents: 1273
diff changeset
557 match_algo = check_algo(start, algos);
eed9376a4ad6 improve algorithm list parsing
Matt Johnston <matt@ucc.asn.au>
parents: 1273
diff changeset
558 if (match_algo) {
eed9376a4ad6 improve algorithm list parsing
Matt Johnston <matt@ucc.asn.au>
parents: 1273
diff changeset
559 if (check_algo(start, new_algos)) {
eed9376a4ad6 improve algorithm list parsing
Matt Johnston <matt@ucc.asn.au>
parents: 1273
diff changeset
560 TRACE(("Skip repeated algorithm '%s'", start))
eed9376a4ad6 improve algorithm list parsing
Matt Johnston <matt@ucc.asn.au>
parents: 1273
diff changeset
561 } else {
eed9376a4ad6 improve algorithm list parsing
Matt Johnston <matt@ucc.asn.au>
parents: 1273
diff changeset
562 new_algos[n] = *match_algo;
eed9376a4ad6 improve algorithm list parsing
Matt Johnston <matt@ucc.asn.au>
parents: 1273
diff changeset
563 n++;
eed9376a4ad6 improve algorithm list parsing
Matt Johnston <matt@ucc.asn.au>
parents: 1273
diff changeset
564 }
eed9376a4ad6 improve algorithm list parsing
Matt Johnston <matt@ucc.asn.au>
parents: 1273
diff changeset
565 } else {
eed9376a4ad6 improve algorithm list parsing
Matt Johnston <matt@ucc.asn.au>
parents: 1273
diff changeset
566 dropbear_log(LOG_WARNING, "This Dropbear program does not support '%s' %s algorithm", start, algo_desc);
eed9376a4ad6 improve algorithm list parsing
Matt Johnston <matt@ucc.asn.au>
parents: 1273
diff changeset
567 }
686
983a817f8e41 - Only request "none" cipher after auth has succeeded
Matt Johnston <matt@ucc.asn.au>
parents: 684
diff changeset
568 c++;
1303
eed9376a4ad6 improve algorithm list parsing
Matt Johnston <matt@ucc.asn.au>
parents: 1273
diff changeset
569 start = c;
eed9376a4ad6 improve algorithm list parsing
Matt Johnston <matt@ucc.asn.au>
parents: 1273
diff changeset
570 }
eed9376a4ad6 improve algorithm list parsing
Matt Johnston <matt@ucc.asn.au>
parents: 1273
diff changeset
571 if (oc == '\0') {
eed9376a4ad6 improve algorithm list parsing
Matt Johnston <matt@ucc.asn.au>
parents: 1273
diff changeset
572 break;
682
4edea9f363d0 Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents: 595
diff changeset
573 }
4edea9f363d0 Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents: 595
diff changeset
574 }
4edea9f363d0 Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents: 595
diff changeset
575 m_free(work_list);
1303
eed9376a4ad6 improve algorithm list parsing
Matt Johnston <matt@ucc.asn.au>
parents: 1273
diff changeset
576 /* n+1 to include a null terminator */
eed9376a4ad6 improve algorithm list parsing
Matt Johnston <matt@ucc.asn.au>
parents: 1273
diff changeset
577 memcpy(algos, new_algos, sizeof(*new_algos) * (n+1));
eed9376a4ad6 improve algorithm list parsing
Matt Johnston <matt@ucc.asn.au>
parents: 1273
diff changeset
578 return n;
682
4edea9f363d0 Add rough support for choosing ciphers/hashes with "-c" or "-m"
Matt Johnston <matt@ucc.asn.au>
parents: 595
diff changeset
579 }
857
c19acba28590 use oldstyle comments
Matt Johnston <matt@ucc.asn.au>
parents: 852
diff changeset
580 #endif /* ENABLE_USER_ALGO_LIST */