comparison common-algo.c @ 1256:506f7681d0f8 coverity

merge up to date
author Matt Johnston <matt@ucc.asn.au>
date Tue, 15 Mar 2016 22:45:43 +0800
parents 739b3909c499
children 139935236c72
comparison
equal deleted inserted replaced
1219:84cf9062718d 1256:506f7681d0f8
25 25
26 #include "includes.h" 26 #include "includes.h"
27 #include "algo.h" 27 #include "algo.h"
28 #include "session.h" 28 #include "session.h"
29 #include "dbutil.h" 29 #include "dbutil.h"
30 #include "kex.h" 30 #include "dh_groups.h"
31 #include "ltc_prng.h" 31 #include "ltc_prng.h"
32 #include "ecc.h" 32 #include "ecc.h"
33 33
34 /* This file (algo.c) organises the ciphers which can be used, and is used to 34 /* This file (algo.c) organises the ciphers which can be used, and is used to
35 * decide which ciphers/hashes/compression/signing to use during key exchange*/ 35 * decide which ciphers/hashes/compression/signing to use during key exchange*/
246 {"ssh-dss", DROPBEAR_SIGNKEY_DSS, NULL, 1, NULL}, 246 {"ssh-dss", DROPBEAR_SIGNKEY_DSS, NULL, 1, NULL},
247 #endif 247 #endif
248 {NULL, 0, NULL, 0, NULL} 248 {NULL, 0, NULL, 0, NULL}
249 }; 249 };
250 250
251 #if DROPBEAR_DH_GROUP1
251 static const struct dropbear_kex kex_dh_group1 = {DROPBEAR_KEX_NORMAL_DH, dh_p_1, DH_P_1_LEN, NULL, &sha1_desc }; 252 static const struct dropbear_kex kex_dh_group1 = {DROPBEAR_KEX_NORMAL_DH, dh_p_1, DH_P_1_LEN, NULL, &sha1_desc };
253 #endif
254 #if DROPBEAR_DH_GROUP14
252 static const struct dropbear_kex kex_dh_group14_sha1 = {DROPBEAR_KEX_NORMAL_DH, dh_p_14, DH_P_14_LEN, NULL, &sha1_desc }; 255 static const struct dropbear_kex kex_dh_group14_sha1 = {DROPBEAR_KEX_NORMAL_DH, dh_p_14, DH_P_14_LEN, NULL, &sha1_desc };
256 #if DROPBEAR_DH_GROUP14_256
253 static const struct dropbear_kex kex_dh_group14_sha256 = {DROPBEAR_KEX_NORMAL_DH, dh_p_14, DH_P_14_LEN, NULL, &sha256_desc }; 257 static const struct dropbear_kex kex_dh_group14_sha256 = {DROPBEAR_KEX_NORMAL_DH, dh_p_14, DH_P_14_LEN, NULL, &sha256_desc };
258 #endif
259 #endif
260 #if DROPBEAR_DH_GROUP16
261 static const struct dropbear_kex kex_dh_group16_sha512 = {DROPBEAR_KEX_NORMAL_DH, dh_p_16, DH_P_16_LEN, NULL, &sha512_desc };
262 #endif
254 263
255 /* These can't be const since dropbear_ecc_fill_dp() fills out 264 /* These can't be const since dropbear_ecc_fill_dp() fills out
256 ecc_curve at runtime */ 265 ecc_curve at runtime */
257 #ifdef DROPBEAR_ECDH 266 #ifdef DROPBEAR_ECDH
258 #ifdef DROPBEAR_ECC_256 267 #ifdef DROPBEAR_ECC_256
284 #endif 293 #endif
285 #ifdef DROPBEAR_ECC_256 294 #ifdef DROPBEAR_ECC_256
286 {"ecdh-sha2-nistp256", 0, &kex_ecdh_nistp256, 1, NULL}, 295 {"ecdh-sha2-nistp256", 0, &kex_ecdh_nistp256, 1, NULL},
287 #endif 296 #endif
288 #endif 297 #endif
298 #if DROPBEAR_DH_GROUP14
299 #if DROPBEAR_DH_GROUP14_256
289 {"diffie-hellman-group14-sha256", 0, &kex_dh_group14_sha256, 1, NULL}, 300 {"diffie-hellman-group14-sha256", 0, &kex_dh_group14_sha256, 1, NULL},
301 #endif
290 {"diffie-hellman-group14-sha1", 0, &kex_dh_group14_sha1, 1, NULL}, 302 {"diffie-hellman-group14-sha1", 0, &kex_dh_group14_sha1, 1, NULL},
303 #endif
304 #if DROPBEAR_DH_GROUP1
291 {"diffie-hellman-group1-sha1", 0, &kex_dh_group1, 1, NULL}, 305 {"diffie-hellman-group1-sha1", 0, &kex_dh_group1, 1, NULL},
306 #endif
307 #if DROPBEAR_DH_GROUP16
308 {"diffie-hellman-group16-sha512", 0, &kex_dh_group16_sha512, 1, NULL},
309 #endif
292 #ifdef USE_KEXGUESS2 310 #ifdef USE_KEXGUESS2
293 {KEXGUESS2_ALGO_NAME, KEXGUESS2_ALGO_ID, NULL, 1, NULL}, 311 {KEXGUESS2_ALGO_NAME, KEXGUESS2_ALGO_ID, NULL, 1, NULL},
294 #endif 312 #endif
295 {NULL, 0, NULL, 0, NULL} 313 {NULL, 0, NULL, 0, NULL}
296 }; 314 };
318 336
319 unsigned int i, len; 337 unsigned int i, len;
320 unsigned int donefirst = 0; 338 unsigned int donefirst = 0;
321 buffer *algolist = NULL; 339 buffer *algolist = NULL;
322 340
323 algolist = buf_new(200); 341 algolist = buf_new(300);
324 for (i = 0; localalgos[i].name != NULL; i++) { 342 for (i = 0; localalgos[i].name != NULL; i++) {
325 if (localalgos[i].usable) { 343 if (localalgos[i].usable) {
326 if (donefirst) 344 if (donefirst)
327 buf_putbyte(algolist, ','); 345 buf_putbyte(algolist, ',');
328 donefirst = 1; 346 donefirst = 1;