comparison common-algo.c @ 1674:ba6fc7afe1c5

use sigtype where appropriate
author Matt Johnston <matt@ucc.asn.au>
date Mon, 06 Apr 2020 23:18:26 +0800
parents d32bcb5c557d
children ae41624c2198
comparison
equal deleted inserted replaced
1668:49cb3cf4bd6f 1674:ba6fc7afe1c5
235 #if DROPBEAR_ECC_521 235 #if DROPBEAR_ECC_521
236 {"ecdsa-sha2-nistp521", DROPBEAR_SIGNKEY_ECDSA_NISTP521, NULL, 1, NULL}, 236 {"ecdsa-sha2-nistp521", DROPBEAR_SIGNKEY_ECDSA_NISTP521, NULL, 1, NULL},
237 #endif 237 #endif
238 #endif 238 #endif
239 #if DROPBEAR_RSA 239 #if DROPBEAR_RSA
240 #if DROPBEAR_RSA_SHA256
241 {"rsa-sha2-256", DROPBEAR_SIGNKEY_RSA_SHA256, NULL, 1, NULL},
242 #endif
243 #if DROPBEAR_RSA_SHA1
240 {"ssh-rsa", DROPBEAR_SIGNKEY_RSA, NULL, 1, NULL}, 244 {"ssh-rsa", DROPBEAR_SIGNKEY_RSA, NULL, 1, NULL},
245 #endif
241 #endif 246 #endif
242 #if DROPBEAR_DSS 247 #if DROPBEAR_DSS
243 {"ssh-dss", DROPBEAR_SIGNKEY_DSS, NULL, 1, NULL}, 248 {"ssh-dss", DROPBEAR_SIGNKEY_DSS, NULL, 1, NULL},
244 #endif 249 #endif
245 {NULL, 0, NULL, 0, NULL} 250 {NULL, 0, NULL, 0, NULL}
308 #if DROPBEAR_KEXGUESS2 313 #if DROPBEAR_KEXGUESS2
309 {KEXGUESS2_ALGO_NAME, KEXGUESS2_ALGO_ID, NULL, 1, NULL}, 314 {KEXGUESS2_ALGO_NAME, KEXGUESS2_ALGO_ID, NULL, 1, NULL},
310 #endif 315 #endif
311 {NULL, 0, NULL, 0, NULL} 316 {NULL, 0, NULL, 0, NULL}
312 }; 317 };
313
314 /* algolen specifies the length of algo, algos is our local list to match
315 * against.
316 * Returns DROPBEAR_SUCCESS if we have a match for algo, DROPBEAR_FAILURE
317 * otherwise */
318 int have_algo(const char* algo, size_t algolen, const algo_type algos[]) {
319
320 int i;
321
322 for (i = 0; algos[i].name != NULL; i++) {
323 if (strlen(algos[i].name) == algolen
324 && (strncmp(algos[i].name, algo, algolen) == 0)) {
325 return DROPBEAR_SUCCESS;
326 }
327 }
328
329 return DROPBEAR_FAILURE;
330 }
331 318
332 /* Output a comma separated list of algorithms to a buffer */ 319 /* Output a comma separated list of algorithms to a buffer */
333 void buf_put_algolist(buffer * buf, const algo_type localalgos[]) { 320 void buf_put_algolist(buffer * buf, const algo_type localalgos[]) {
334 321
335 unsigned int i, len; 322 unsigned int i, len;